MS Word Vba embeds object shown as icon ok but how do I force icon size to fit table

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

NateofCA

Thread Starter
Joined
Feb 18, 2010
Messages
1
Hi.
The code below will do the following if you have a table set up in WORD:
1. Sequence down a column of cells one after another while:
2. being given the choice to embed a selectable pdf file from a File Open dialog popup after which
3. the embedded object is displayed as a icon ( icon set always same set in code)
4. goes to next lower cell and repeats from step 2
5. keeps doing this until you click Cancel in the File Open dialog box

My question is how do I make the icon conform a set size after it is embedded? Right now I have to go back and resize all the icons after I finish the embedding. I think the trick is to use a 'With' loop but haven't figured it out yet. Here's the code. Thanks for your help:
--------------------------------------------------------------

Sub EmbedPDFAndDisplayIcon()
Dim d As Dialog
Dim r As Word.Range
Dim p As Object
Dim vrtSelectedItem As Variant
Do
For Each r In ActiveDocument.StoryRanges
Dim fd As FileDialog(msoFileDialogOpen)
ActiveWindow.ScrollIntoView Selection.Range, True
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
Selection.InlineShapes.AddOLEObject ClassType:="AcroExch.Document", _
FileName:=vrtSelectedItem _
, LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\Program Files\Adobe\Acrobat 6.0\Reader\acrord32.exe", IconIndex:=0, _
IconLabel:= _
"MyPlot.pdf"
MsgBox "Select cancel to Save. Item embedded"
Next vrtSelectedItem
Selection.MoveDown Unit:=wdLine, Count:=1
'The user pressed Cancel.
Else
Exit Do
ActiveDocument.Save
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
'Declare a variable as a FileDialog object.
Next r
Loop
Selection.MoveDown Unit:=wdLine, Count:=1

End Sub
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top