Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hello,
I am trying to do a Mail Mege with VB6 and MS Word 2002 which will work fine for the first one document. However, if I select ther merge document a second time it blows on the OpenDataSource statement with the error "The remote server machine does not exist or is unavailable". I found several instances of this on Google but unfortunately the solution was not posted. TIA Vic Here's the code: Private Sub mnuCoverLetter_Click() Dim strLoginName As String Dim strMyDocuments As String Dim WordWasNotRunning As Boolean ' Flag For final word unload Dim strDocument As String Dim strWhereClause As String Dim WordApp As Word.Application Dim WordDoc As Word.Document Dim oApp As Word.Application Set oApp = CreateObject("Word.Application") On Error GoTo ErrorHandler Set WordApp = GetObject(, "Word.Application") Set WordDoc = WordApp.Documents.Add(strMyDocuments & "\" & strDocument) With WordDoc strWhereClause = "WHERE JobID = '" & frmMain.txtJobid & "'" ActiveDocument.MailMerge.OpenDataSource Name:= _ "C:\Documents and Settings\vic.HOME\My Documents\My Data Sources\Hughes_Jobs vuCoverLetter.odc" _ , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _ AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _ WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _ format:=wdOpenFormatAuto, Connection:= _ "Provider=MSDASQL.1;Persist Security Info=True;Extended Properties=""DSN=HughesSupply;Description=Hughes Supply Jobs;UID=vic;APP=Microsoft Office XP;WSID=VIC-XP;DATABASE=Hughes_Jobs;Trusted_Connection=Yes"";I nitial Catalog=Hughes_Jobs" _ , SQLStatement:="SELECT * FROM ""vuCoverLetter""", SQLStatement1:=strWhereClause, _ SubType:=wdMergeSubTypeOther ActiveDocument.MailMerge.MainDocumentType = wdFormLetters ActiveDocument.MailMerge.Destination = wdSendToNewDocument End With WordApp.Visible = True WordApp.Application.Activate Set WordApp = Nothing Set WordDoc = Nothing Set oApp = Nothing Exit Sub ErrorHandler: MsgBox "Error: " & Err.Number & Err.Description End Sub |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I eliminate numerous "Mail Merge..." under my tool bar? | Microsoft Word Help | |||
Mail merge toolbar unavailable after SP3 | Mailmerge | |||
How do I mail merge when only merge document is shown in tools? | Microsoft Word Help | |||
Mail Merge Problem | Mailmerge | |||
Using Hyperlinks in Mail Merge IF...THEN...ELSE Statements | Mailmerge |