![]() |
|
#5
|
||||
|
||||
|
Put the following function in the same module
Code:
Private Function BrowseForFile(Optional strTitle As String) As String
Dim fDialog As FileDialog
On Error GoTo err_Handler
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.TITLE = strTitle
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Graphics Files", "*.jpg,*.png,*.bmp"
.InitialView = msoFileDialogViewList
If .Show <> -1 Then GoTo err_Handler:
BrowseForFile = fDialog.SelectedItems.Item(1)
End With
lbl_Exit:
Exit Function
err_Handler:
BrowseForFile = vbNullString
Resume lbl_Exit
End Function
Code:
Dim oShp As Shape
Dim strFName As String
strFName = BrowseForFile("Select the picture to insert")
Set oShp = ActiveDocument.Shapes.AddPicture(FileName:=strFName, _
SaveWithDocument:=True)
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to create a "Font color" button and a "Highlight text" button in the Quick Launch toolbar ? | gloub | Word | 12 | 02-19-2019 03:19 PM |
| Help with a Command Button | dkohnken | Word VBA | 5 | 03-18-2015 10:13 PM |
Option Button help
|
ksigcajun | Word VBA | 1 | 01-15-2015 01:36 PM |
How to run two button macros with one button?
|
Geza59 | Excel Programming | 1 | 02-14-2013 12:11 AM |
| Macro Button | B2W | Excel | 2 | 06-18-2010 09:36 AM |