
Linking images to a document doesn't show them
Hi all
I have written a macro that will look in a given directory and its
subdirectories for images, and will import them into a new document. The
macro will also add the full path to the image below the image.
All of this works, except for one small thing: the user can choose to Link
the files or to embed the files. When embedding, it works.
When linking however, it doesn't. Word does spend a whole lot of time
executing the macro (much longer than when embedding), the file gets saved
and has about the same size as the same document with embedded images, but I
can't see the images.
When I close and reopen the document, Word gives me approximately the same
wordcount (you know, in the statusbar) as the document with embedded
pictures. However, when I ask for a wordcount (Tools menu) it returns zero.
When I save the file after that wordcount and reopen it, the wordcount in
the statusbar also says 0 words. The size of the document itself doesn't
change.
Below is an excerpt of my code (this code gets called from another function,
in a loop):
------------------------------
Private Sub DoInsert(ByVal strPicture As String, ByVal blnLink As Boolean)
'
' Move to the last character: new insertion point
Selection.SetRange m_objDocument.Characters.Count,
m_objDocument.Characters.Count
' Insert the next picture at the insertion point
If (Not blnLink) Then
m_objDocument.InlineShapes.AddPicture strPicture, blnLink, , _
m_objDocument.range(m_objDocument.Characters.Count - 1,
m_objDocument.Characters.Count - 1)
Else
m_objDocument.InlineShapes.AddOLEObject , strPicture, True, False, ,
, , _
m_objDocument.range(m_objDocument.Characters.Count - 1,
m_objDocument.Characters.Count - 1)
End If
'
Selection.SetRange m_objDocument.Characters.Count - 1,
m_objDocument.Characters.Count
' Insert the name of the file
Selection.InsertAfter vbCrLf & strPicture
' Move to the last position
Selection.SetRange m_objDocument.Characters.Count,
m_objDocument.Characters.Count
' Insert a page break
Selection.InsertBreak wdPageBreak
'
End Sub
------------------------
What I find strange is that I can't even see the path to the image. No
errors occur, and when I debug the code everything seems fine.
Any help?
Sven.