SavePictureWithDocument

D

DA

Hi GP

Not sure if this will do the trick, but try adding
a "DoEvents" where you've got of your Stop.

Regards,
Dennis
-----Original Message-----
Hi,

I've got the code below. If I don't add the "Stop" the
image appears blank in the resulting word doc. If I put
the "Stop" the image appears fine. It appears to be a
timing issue where Word isn't done with
SavePictureWithDocument when SaveAs is called. Anyone
know of a way to check if Word is done with
SavePictureWithDocument or if its' still busy before
calling SaveAs? I'm hoping to avoid just adding a "wait"
call before SaveAs to give Word time to do it's thing
because the wait time would be machine dependant unless I
make it a really long wait - which I'd like to avoid.
Thanks,
GP

========

Public Sub TestEmebedImages()

Dim objWord As Word.Application
Dim objWordDoc As Word.Document
Dim objInlineShape As InlineShape

Set objWord = Application
Set objWordDoc = Documents.Open("C:\Temp\1.htm")

For Each objInlineShape In objWordDoc.InlineShapes
If objInlineShape.Type =
wdInlineShapeLinkedPicture Then
objInlineShape.LinkFormat.SavePictureWithDocument = False
ThenobjInlineShape.LinkFormat.SavePictureWithDocument = True
End If
End If
Next

Stop 'After Adding This The Image Appears Fine

objWordDoc.SaveAs "C:\Temp\NewSave" & Hour(Now) &
Minute(Now) & Second(Now) & ".doc", wdFormatDocument
 
C

Chad DeMeyer

If, and only if, "objInlineShape.LinkFormat.SavePictureWithDocument = True"
dirties the document (i.e., sets .Saved to False), you could try setting
"objWordDoc.Saved = True" before each LinkFormat change, then something like

Do While objWordDoc.Saved
'Short pause
Loop

Hope that helps.
Regards,
Chad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top