I am using the following code to open a word document and insert two pictures:-
Public WordApp As New Word.Application
Public TestDoc As Word.Document
Dim Sel As Word.Selection
Private Sub LPCBtn_Click()
Dim LogoRange As Word.Range
Set TestDoc = WordApp.Documents.Open("C:\Documents and Settings\Robert\Desktop\Print Single Letter\TestDocument.doc"
Set TestDoc = ActiveDocument
With TestDoc
Set LogoRange = ActiveDocument.Bookmarks("TopLogo"
.Range
Selection.InlineShapes.AddPicture FileName:="C:\Documents and Settings\Robert\Desktop\Print Single Letter\LPCLogo.tiff", LinkToFile:=False, SaveWithDocument:=True, Range:=LogoRange
Set LogoRange = ActiveDocument.Bookmarks("BottomLogo"
.Range
Selection.InlineShapes.AddPicture FileName:="C:\Documents and Settings\Robert\Desktop\Print Single Letter\LPCFooter.tiff", LinkToFile:=False, SaveWithDocument:=True, Range:=LogoRange
End With
WordApp.Visible = True
Set TestDoc = Nothing
Set WordApp = Nothing
End Sub
The problem is when i first click the button, everything works fine. I then close word and try and click the button again and I get an error on this line:-
Set TestDoc = ActiveDocument
"The remote server machine does not exist"
Any ideas?
Public WordApp As New Word.Application
Public TestDoc As Word.Document
Dim Sel As Word.Selection
Private Sub LPCBtn_Click()
Dim LogoRange As Word.Range
Set TestDoc = WordApp.Documents.Open("C:\Documents and Settings\Robert\Desktop\Print Single Letter\TestDocument.doc"
Set TestDoc = ActiveDocument
With TestDoc
Set LogoRange = ActiveDocument.Bookmarks("TopLogo"
Selection.InlineShapes.AddPicture FileName:="C:\Documents and Settings\Robert\Desktop\Print Single Letter\LPCLogo.tiff", LinkToFile:=False, SaveWithDocument:=True, Range:=LogoRange
Set LogoRange = ActiveDocument.Bookmarks("BottomLogo"
Selection.InlineShapes.AddPicture FileName:="C:\Documents and Settings\Robert\Desktop\Print Single Letter\LPCFooter.tiff", LinkToFile:=False, SaveWithDocument:=True, Range:=LogoRange
End With
WordApp.Visible = True
Set TestDoc = Nothing
Set WordApp = Nothing
End Sub
The problem is when i first click the button, everything works fine. I then close word and try and click the button again and I get an error on this line:-
Set TestDoc = ActiveDocument
"The remote server machine does not exist"
Any ideas?