Hello all,
I have the following code:
Private Sub CommandButton1_Click()
Selection.GoTo What:=wdGoToLine, Which:=wdGoToNext, Count:=2
Call InsertWordObject
End Sub
Sub InsertWordObject()
Dim FoundFile As Variant
Dim vName As Variant
With Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
If .Show = -1 Then
For Each FoundFile In .SelectedItems
vName = FoundFile
On Error GoTo Alternate
Selection.InlineShapes.AddOLEObject FileName:=vName, LinkToFile:=True, _
DisplayAsIcon:=True, IconFileName:=vName, IconIndex:=(0), IconLabel:="Document 1"
GoTo NextShape
Alternate:
Selection.InlineShapes.AddOLEObject ClassType:="Package", FileName:=vName, _
LinkToFile:=True, DisplayAsIcon:=True, IconFileName:=vName, IconIndex:=(0), IconLabel:="Document 1"
NextShape:
Next
End If
End With
End Sub
When manually creating an attached OLEObject, word automatically selects the relevant icon for each program, and uses the file name.
I am struggling to figure out how to create the same outcome with VBA.
Any help would be greatly appreciated.
Thank you,
Jack.
Bookmarks