Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automated PasteSpecial (XP)

    I have recently been compiling a document which contains other documents within it, I have chosen to embed these other documents (.doc, .pdf, .xls) by doing Paste Special, Paste File, Display Icon to create a respective document icon in Word.

    Users can then doulble click this Icon and view the document in its native application.

    I really liked this idea and decided to create a macro to automate the tedious Edit | Paste Special | <setting options - same every time > | OK

    I found some stuff on the web on how to manipulate dialog boxes, but only can get 2 properties to work.

    Here's my code:

    Sub pasteIcon()
    Dim myD As Dialog
    Set myD = Dialogs(wdDialogEditPasteSpecial)
    With myD
    .DisplayIcon = 1
    .Caption = InputBox("Name for file?")
    .Show
    End With
    End Sub

    This presents me (say i have coped a pdf file) with the paste special dialog box, 'Display as Icon' is selected, and the Caption is set (whatever i typed in the inputbox).

    If I add the .update command before the .show, then these properties don't get set?!!? I wanted to do this so i could use the .update, then .execute commands and avoid having the dialog box popping up each time.

    Also, I could get the .Link and other properties of the wdDialogEditPasteSpecial to work.

    any thoughts on these issues?
    Thanks,

    pmatz

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Automated PasteSpecial (XP)

    Do you really want to display the Paste Special dialog, or would you prefer to paste the item as an icon directly?

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automated PasteSpecial (XP)

    I would like to paste the file as an icon directly, embedded in the word file so it can be accessed by double clicking it.

    Also, wonder why i cant manipulate said code, but not as important as getting my macro to work smoothly and easily ;0)

    ... i get the impression you have a solution mr Hans?
    Thanks,

    pmatz

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Automated PasteSpecial (XP)

    Try this:
    <code>
    Sub PasteIcon()
    Dim strLabel As String
    strLabel = InputBox("Please enter a label for the icon.")
    Selection.PasteSpecial DataType:=11, _
    Placement:=wdInLine, _
    DisplayAsIcon:=True, _
    IconFileName:="C:WINDOWSsystem32packager.exe", _
    IconIndex:=0, _
    IconLabel:=strLabel
    End Sub</code>

  5. #5
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automated PasteSpecial (XP)

    Thanks hans, but I want the Icon to be dynamic, ie wither word, pdf, whatever file i am pasting.
    Thanks,

    pmatz

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Automated PasteSpecial (XP)

    That would be difficult, I'd live with the generic icon.

  7. #7
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automated PasteSpecial (XP)

    Cool, well I'l live with the dialog box option, not a biggie really. Thanks though Hans.
    Thanks,

    pmatz

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Automated PasteSpecial (XP)

    The Update method doesn't do what you want. An example of its use is provided in the Help file: you change the font of the selection, then call the Update method of the Font dialog to reflect this change before displaying it.

    Manipulating dialog boxes in VBA is rather wobbly, not all the properties listed in the Help file work as advertised. You can use SendKeys, although that is not 100% dependable either. For example, to select the option "Paste link", use
    <code>
    SendKeys "%L"
    </code>
    before showing the dialog. %L sends Alt+L, where L is the underlined letter in "Paste link".

  9. #9
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automated PasteSpecial (XP)

    Good old send keys [img]/forums/images/smilies/smile.gif[/img] yes, I agree with the wobblyness of said MS Dialog boxes.

    Still, its all good fun.

    Take care
    Thanks,

    pmatz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •