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

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.




Answer this question

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

  • Edward1

    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



  • 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

    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.


  • How to get the filename into the "Insert Picture" dialogue?