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

    VBA Merge / XP (Word 2002)

    Is there a simple way to program a merge in Word 2002 that doesn't get the Wizard/Task pane involved? Also, I'm finding that a dialog to "Confirm Data Source" occasionally pops up and waits for user response. This doesn't happen all the time... even with the same form and data files. Thanks, Richard Barrett

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: VBA Merge / XP (Word 2002)

    Ah yes, the Mail Merge in Word 2002! As far as I can tell there isn't any way to disable the wizard for Mail Merges done manually. You could of course write some code to perform the function, and that should bypass the wizard, but it isn't exactly trivial to do. And yes, the "Confirm Data Source" does seem, shall we say, erratic in behavior. In particular, if you are using a secured Access database for the data source, things get weird depending on which operating system you are using. I must also confess I haven't tried testing the behavior with SP1 applied - my suspicion is that there my have been some bug fixes in this area, but the documentation doesn't confirm that.
    Wendell

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

    Re: VBA Merge / XP (Word 2002)

    I guess I wasn't clear. I put VBA in the subject, but didn't indicate in the post itself that the merge in question is done via code. I'm using code similar to what I've used in Word 2000, and it does the job.... except for that pesky "confirm data source" dialog and the fact that the wizard opens in the task pain, making the process look messy. Sometimes the output document fills only about two-thirds of the dialog window, as if leaving room for the task pain which isn't there. There's nothing to grab to drag the right edge of the document to the right edge of the window. Can you suggest anything new, knowing that I'm doing this with a VBA macro? Thanks.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: VBA Merge / XP (Word 2002)

    Are you actively setting the data source in your code? The following code snippet is from an OLE Automation routine that executes a merge from Access in this fashion:

    <font color=blue> With appWord
    .ActiveDocument.MailMerge.OpenDataSource Name:=strDBName, _
    LinkToSource:=True, Connection:=strQuery, _
    SubType:=wdMergeSubTypeWord2000
    .ActiveDocument.MailMerge.Destination = wdSendToNewDocument
    .ActiveDocument.MailMerge.Execute
    .Documents(strWordDoc).Close SaveChanges:=wdDoNotSaveChanges
    End With
    </font color=blue>
    where strDBName is the database name and strQuery is the name of a query in that database. One trick we have used is to save the document with no active data source - that seems to make Word happier when it opens - and then set the data source in code. What is the data source you are using?
    Wendell

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

    Re: VBA Merge / XP (Word 2002)

    Thank you. We are setting the data source, and we do not save the "header" info with the data source in the form document. I believe our code is somewhat more complex than this, and perhaps simplifying it will help matters.

    Thanks again.

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

    Re: VBA Merge / XP (Word 2002)

    Oh... and the data source is an RTF format file which we have converted from ASCII output from Lotus Notes. Perhaps there's a better type of data to convert to?

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

    Re: VBA Merge / XP (Word 2002)

    One other question, please...

    What is the SubType property of the OpenDataSource method? I see it in the Object Brower, but I can't find any reference to it in the Help file.

  8. #8
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: VBA Merge / XP (Word 2002)

    Well, several questions - I'll do my best in order, but don't have a great deal of experience with automation of merges within Word - we do it mostly from Access or Outlook. Anyhow:

    <<Thank you. We are setting the data source, and we do not save the "header" info with the data source in the form document. I believe our code is somewhat more complex than this, and perhaps simplifying it will help matters.>>
    I did leave out some of the automation stuff at the beginning, so the code isn't complete, but you shouldn't need it when running directly from word. And you may want to either save the "Header" in this case, or actually set it in code - something I've not tried to do. I presume your datasource is always in the same file location - otherwise you would need the common dialog boxes for selecting a path and file.

    <<Oh... and the data source is an RTF format file which we have converted from ASCII output from Lotus Notes. Perhaps there's a better type of data to convert to? >>
    Actually, the ASCII output directly from Notes should work as well, or even better, especially if it's tab or comma delimited - you could skip the step of going to RTF. Does the data contain some sort of header row as the first line - if so you might want to get rid of it?

    <<What is the SubType property of the OpenDataSource method? I see it in the Object Brower, but I can't find any reference to it in the Help file. >>
    It is a new property added in Word 2002 to force the merge to use DDE - otherwise it will use the OLEDB method, which is probably what's actually causing your prompt. Take a look at Microsoft Knowledge Base article Q289830. Hopefully the info in it will help you solve your problem.
    Wendell

Posting Permissions

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