Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word objects in a multi version environment

Status
Not open for further replies.

dpimental

Programmer
Jul 23, 2002
535
US
All, I am using some code to automate merging word documents. But, I have to refernce the correct ms word version. But the users have different versions of owrd (2007, 2010). How do I avoid the errors I would get, if I set the version to 14 and a user only has 12.

Is there a way to create a word merge object without setting the reference to the version of ms word?

Here is some of my code.

Code:
Dim WordApp As Word.Application
    Dim WordDoc As Word.Document
    Dim WordMerge As Word.MailMerge
    Dim strlnk As String
    Dim dbpathname As String
    dbpathname = "Z:\Database\RMOracleMailMerge2012.mdb"
    strlnk = "Z:\Letters\Release\Active\12FnlReleaseAckStd_David.doc"
    Set WordApp = New Word.Application
    
    Set WordDoc = WordApp.Documents.OPEN(fileName:="""" & strlnk & """", _
        ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
        WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
        wdOpenFormatAuto, XMLTransform:="")
    Set WordMerge = WordDoc.MailMerge
      WordMerge.OpenDataSource _
        NAME:=dbpathname, _
        LinkToSource:=True, AddToRecentFiles:=False, _
        Connection:="Query Release_Mail_Mege", _
        SQLStatement:="Select * FROM [Release_Mail_Mege] where [ORDER_ID] = 950711"

David Pimental
(US, Oh)
 
Thanks, Duane. I can't believe that I didn't think of that!

Thanks again!

David Pimental
(US, Oh)
 
Duane, thanks again for the help - I have the code that I need that opens a mail merge doc, merges it with the db data to a new file, then closes the mail merge doc.

But, how do make the new doc the active window, so it comes to the front?

David Pimental
(US, Oh)
 
Have a look at the AppActivate instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, I found it. It's the app.activate.

Thanks to both of you for your help.

David Pimental
(US, Oh)
 
One last thing. Everything is running fine and I can automate the merging of data. But when it's finished, it prompts me to save the merged document.

Question. How can I keep the process from prompting the user to save the new document?

David Pimental
(US, Oh)
 
All, I found the answer - thanks - it was an issue with my code.

David Pimental
(US, Oh)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top