Jess Chan


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.





Re: How to get the filename into the "Insert Picture" dialogue?

Andy Pope


Hi,

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







Re: How to get the filename into the "Insert Picture" dialogue?

Jess Chan

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







Re: How to get the filename into the "Insert Picture" dialogue?

Andy Pope

You can use the .Name property I think to get the name.
But you wanted to set the name before showing, which you can not do.