MS Word Mail Merge error "The remote server machine does not exist or is unavailable"

ffleitas

Registered User.
Local time
Today, 06:46
Joined
Oct 19, 2009
Messages
14
MS Word Mail Merge error "The remote server machine does not exist or is unavailable"

Greetings,

I have researched everywhere on the web and have not been able to figure out the problem with the code below.

When I run this code below for the first time I don't receive any errors. Yet, when I run it for a second time I receive the error message below:

"The remote server machine does not exist or is unavailable"

If I exit MS Access and return to the same program it works well but again the second time it gives the error.

Any help or suggestions?

Thank you.
Felix - Miami, Florida
----------------------------------------------------------------
'Mail Merge with data.txt file as the source
Dim objWord As Word.Document


'Begins Mail Merge

DoCmd.RunCommand acCmdSaveRecord
DoCmd.Requery

DoCmd.RunMacro "mcr_Word_Collection_Delete"
DoCmd.RunMacro "mcr_Word_Collection_Add_part_2"

WriteFlatFile "C:\program files\iqoq\docs\data.txt", ","

Set objWord = GetObject("c:\program files\iqoq\docs\CFF13001_rev_18.docx", "Word.Document")


'Make Word Visible
objWord.Application.Visible = True


'Set Mail Merge Data Source
objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\iqoq\docs\data.txt", _
LinkToSource:=True


'Execute the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Activate
objWord.Close wdDoNotSaveChanges

'Call finaltable
Set objWord = Nothing

strProtocol = Form_frm_Steps_1.PROTOCOL_DOC_NO.Value
strSaveAsName = strProtocol
strSaveLocation = "C:\Program Files\iqoq\protocols\"


'Message to return if file exists.
strMsg2 = "Do you want to replace the existing file " & strSaveAsName & "?"
'Check if the file exists.

If Dir("C:\Program Files\iqoq\protocols\" & strSaveAsName & "*") <> "" Then
'If file does exist, prompt with warning message.
'Check value of button clicked in message box.
Select Case MsgBox(strMsg2, vbYesNoCancel + vbExclamation)
Case vbYes
'If Yes was chosen, save and overwrite existing file.
ActiveDocument.SaveAs FileName:=strSaveLocation & strSaveAsName

Case vbNo
'If No was chosen, prompt for file name
With Dialogs(wdDialogFileSaveAs)
.Name = strSaveLocation & ""
.Show
End With
Case Else
'If Cancel was chosen, do nothing.
End Select


Else

'If file does not exist, save without prompting.
ActiveDocument.SaveAs FileName:=strSaveLocation & strSaveAsName

End If
 
Re: MS Word Mail Merge error "The remote server machine does not exist or is unavaila

You have not said which line is thowing the error, also you do not appear to have .Quit after your .Close

David
 
Re: MS Word Mail Merge error "The remote server machine does not exist or is unavaila

Hi David,
I had the .Quit right after the .Close before but it gave me an error about losing connection

The line with the error is as follows:
ActiveDocument.SaveAs FileName:=strSaveLocation & strSaveAsName

Felix
 
Re: MS Word Mail Merge error "The remote server machine does not exist or is unavaila

Is there a slash between he two variables? ie the path and the filename.

David
 
Re: MS Word Mail Merge error "The remote server machine does not exist or is unavaila

I have this in the code:

strProtocol = Form_frm_Steps_1.PROTOCOL_DOC_NO
strSaveAsName = strProtocol
strSaveLocation = "C:\Program Files\iqoq\protocols\"

I don't know if this is what you are asking for ?
 
Re: MS Word Mail Merge error "The remote server machine does not exist or is unavaila

What I was asking was in your code line containing

strSaveLocation & strSaveAsName

Did strSaveLocation have a trailing "\" or not

Because if strSaveLocation was "C:\Temp" and strSaveFile was "Fred.xls" the whole line would read "C:\TempFred.xls"

David
 

Users who are viewing this thread

Back
Top Bottom