1
votes

I have a word document. In the word document I have command button.

What I am after is when the user presses the command button it would open a dialog box so that the user can embed a file and display as an icon within the word document.

How WOULD I do this in VBA?

Ultimately I would like the following:

  1. User clicks on button
  2. Dialog box opens for user to choose file (any type)
  3. User clicks OK
  4. File is embedded(not linked) in document as Icon
  5. If user click cancel, dialog window closes.
1
Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on Stack Overflow. See "Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?. BTW, it's "Thanks in advance", not "Thanks in advanced".John Saunders

1 Answers

2
votes

Okay here is start

Option Explicit
Sub AddFileIcon()
    SendKeys "%F{TAB 4} {TAB 5}"
    Dialogs(wdDialogInsertObject).Show
End Sub

Now you Create Button :-) and call the Macro

Here is help full Links

VBA SendKeys


Word Dialog Boxes