How to determine type of inserting of image into document?

A

avkokin

Hello. I need to determine type of inserting of selected image: embed
or related (Selection.Fields(1).Type = wdFieldIncludePicture). How can
I do it?
Thank you very much!
 
H

Helmut Weber

Hallo Anton,

something along these lines:

Sub Test677789()
Dim Linked As Boolean
Dim Embedded As Boolean
With Selection
If .InlineShapes.Count = 0 Then
MsgBox "no inlineshape selected"
Exit Sub
End If
If .InlineShapes.Count > 1 Then
MsgBox "more than one inlineshape selected"
Exit Sub
End If
If .InlineShapes.Count = 1 Then
If .InlineShapes(1).Type = wdInlineShapeLinkedPicture Then
Linked = True
If .InlineShapes(1).LinkFormat.SavePictureWithDocument Then
Embedded = True
End If
End If
If .InlineShapes(1).Type = wdInlineShapePicture Then
Embedded = True
End If
End If
End With
If Linked And Embedded Then
MsgBox "Linked and Embedded"
End If
If Linked And Not Embedded Then
MsgBox "Linked"
End If
If Embedded And Not Linked Then
MsgBox "Embedded"
End If
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
A

avkokin

Hallo Anton,

something along these lines:

Sub Test677789()
Dim Linked As Boolean
Dim Embedded As Boolean
With Selection
   If .InlineShapes.Count = 0 Then
      MsgBox "no inlineshape selected"
      Exit Sub
   End If
   If .InlineShapes.Count > 1 Then
      MsgBox "more than one inlineshape selected"
      Exit Sub
   End If
   If .InlineShapes.Count = 1 Then
      If .InlineShapes(1).Type = wdInlineShapeLinkedPicture Then
         Linked = True
         If .InlineShapes(1).LinkFormat.SavePictureWithDocumentThen
            Embedded = True
         End If
      End If
      If .InlineShapes(1).Type = wdInlineShapePicture Then
         Embedded = True
      End If
End If
End With
If Linked And Embedded Then
   MsgBox "Linked and Embedded"
End If
If Linked And Not Embedded Then
   MsgBox "Linked"
End If
If Embedded And Not Linked Then
   MsgBox "Embedded"
End If
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Helmut, Riesige Danke!
 

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