K
Kenny
I have written some code to insert two gif files into a
word document. The code seems to work fine during the
first execution, but as soon as it runs again for the
second time i get error 462: remote server does not exist
or can't be found. It happens on the first AddPicture
statement...anyone have any ideas...thanks in advance.
here is the code:
' create the file path for the first GIF file
lsGIFImage = mid(psSourceFilePath, 1, Len
(psSourceFilePath) - 4) & ".gif"
Set lrWord = New Word.Application
lrWord.DisplayAlerts = wdAlertsNone
' create a new document from a template
Set lrDoc = lrWord.Documents.Add("ROMSWordTemplate1")
If lrDoc Is Nothing Then
lrWord.Quit wdDoNotSaveChanges
Set lrWord = Nothing
CreateOutputReport = False
Exit Function
End If
' insert the GIF's (this is where i get the error the
second time to code runs. it works the first time
thru!
Set lrShape = lrDoc.Shapes.AddPicture(lsGIFImage,
False, True, InchesToPoints(1.5), 1, InchesToPoints(6),
InchesToPoints(3.5))
lrDoc.Shapes.AddPicture mid(lsGIFImage, 1, Len
(lsGIFImage) - 4) & "-b.gif", False, True, 1,
lrShape.Height + 10
Set lrShape = Nothing
' save the new document with this file name...
lrDoc.SaveAs mid(psSourceFilePath, 1, Len
(psSourceFilePath) - 4) & ".doc"
' exit and clean up
Set lrDoc = Nothing
lrWord.Quit wdDoNotSaveChanges
Set lrWord = Nothing
word document. The code seems to work fine during the
first execution, but as soon as it runs again for the
second time i get error 462: remote server does not exist
or can't be found. It happens on the first AddPicture
statement...anyone have any ideas...thanks in advance.
here is the code:
' create the file path for the first GIF file
lsGIFImage = mid(psSourceFilePath, 1, Len
(psSourceFilePath) - 4) & ".gif"
Set lrWord = New Word.Application
lrWord.DisplayAlerts = wdAlertsNone
' create a new document from a template
Set lrDoc = lrWord.Documents.Add("ROMSWordTemplate1")
If lrDoc Is Nothing Then
lrWord.Quit wdDoNotSaveChanges
Set lrWord = Nothing
CreateOutputReport = False
Exit Function
End If
' insert the GIF's (this is where i get the error the
second time to code runs. it works the first time
thru!
Set lrShape = lrDoc.Shapes.AddPicture(lsGIFImage,
False, True, InchesToPoints(1.5), 1, InchesToPoints(6),
InchesToPoints(3.5))
lrDoc.Shapes.AddPicture mid(lsGIFImage, 1, Len
(lsGIFImage) - 4) & "-b.gif", False, True, 1,
lrShape.Height + 10
Set lrShape = Nothing
' save the new document with this file name...
lrDoc.SaveAs mid(psSourceFilePath, 1, Len
(psSourceFilePath) - 4) & ".doc"
' exit and clean up
Set lrDoc = Nothing
lrWord.Quit wdDoNotSaveChanges
Set lrWord = Nothing