Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Odd Error (Word XP SP2)

    Our users often perform merges with a data file which is available to them. We have provided a custom toolbar that assists in setting up the form document and merging. A drop-down menu lists the available fields, and another control performs the merge.

    There's one unusual problem. The first time in the Word session that one of the merge fields is inserted, an error message appears: "Project is unviewable." The caption of the windows is "Project locked".... even when the project is not locked. (It's the only global template.)

    The code is as follows:

    Sub InsertMailingAddressField()
    ActiveDocument.Fields.Add Range:=Selection.Range, Type:=wdFieldMergeField _
    , Text:="""MailingAddress"""
    End Sub

    After the field is inserted into the document, the next time the user hits Enter or types anything on the keyboard, the error message appears. After hitting OK, there is no further problem.

    Can anyone offer an idea or suggestion?

    Thanks,
    Richard Barrett

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Odd Error (Word XP SP2)

    Only things that comes to mind are the possibilities that there's no valid selection for the insertion of a field or that the target document isn't the ActiveDocument. But the field inserts fine. Hmmm... Are you monitoring the WindowSelectionChange event by any chance?

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Odd Error (Word XP SP2)

    No, none of the above. The document is clearly the active document... the field inserts as expected and the macro ends. The error message displays when I next try to type in the document.

    I exported everything from the template, created a new template and even re-wrote this module of code from scracth. I still got the error. I then copied the code into its own template, and I no longer get the error. I don't think it's a true error. The caption "Project locked" appears even when the template is unlocked. And the error displays when I have the template open, discounting "Project is unviewable".

    A real mystery!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •