Our company written a marco that used in MS Words and it as same as the "insert -> picture -> from file" dialogue,
but we want to enhance it to get the filename automatically when the dialogue box is opened to instead of blank.
Our company written a marco that used in MS Words and it as same as the "insert -> picture -> from file" dialogue,
but we want to enhance it to get the filename automatically when the dialogue box is opened to instead of blank.
How to get the filename into the "Insert Picture" dialogue?
Edward1
Looks like the built-in dialog does not take a initial filename argument.
You can change the folder using,
Options.DefaultFilePath(wdPicturesPath) = "C:\"
Instead try the Filedialog object.
Dim dlgFile As FileDialog
Set dlgFile = Application.FileDialog(msoFileDialogFilePicker)
With dlgFile
.Filters.Add "Images", "*.bmp; *.gif; *.jpg; *.jpeg", 1
.InitialFileName = "c:\temp\happy"
.InitialView = msoFileDialogViewThumbnail
.Show
If .SelectedItems.Count > 0 Then
MsgBox .SelectedItems.Item(1)
End If
End With
Christian Frießnegg
Do you mean I cannot not get the filename if I use the dialogs that provided by MS as below code
With Dialogs(wdDialogInsertPicture)
.Show
End With
klei0777
But you wanted to set the name before showing, which you can not do.