1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Business Applications' started by NateofCA, Feb 18, 2010.

Thread Status:
Not open for further replies.
  1. NateofCA

    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
     
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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/903996

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice