show images in word file doenst work RRS feed

  • Question

  • We want to show images, the images located on the same location of the word file but nothing happens.

    varPadHuidigeDocumentFoto = ActiveDocument.Path & "/"

        'MsgBox varPadHuidigeDocument

        'ChDir varPadHuidigeDocumentFoto

        With Application.Dialogs(wdDialogInsertPicture)

            .Name = varPadHuidigeDocumentFoto


        End With

    Tuesday, September 25, 2018 7:25 AM

All replies

  • As you have discovered, that doesn't work. However the following should work for you

    Sub Macro1()
        Dim varPadHuidigeDocumentFoto As String
        varPadHuidigeDocumentFoto = ActiveDocument.Path
        Selection.InlineShapes.AddPicture BrowseForFile(varPadHuidigeDocumentFoto, "Select image")
    End Sub
    Function BrowseForFile(strPath As String, Optional strTitle As String) As String
    'Graham Mayor - - Last updated - 25 Sep 2018' 
    'strTitle is the title of the dialog box'
    Dim fDialog As FileDialog
        On Error GoTo err_Handler
        ChDir strPath
        Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
        With fDialog
            .Title = strTitle
            .AllowMultiSelect = False
            .Filters.Add "Pictures", "*.jpg,*.jpeg,*.png,*.bmp,*.gif,*.tif,*.tiff"
            .InitialView = msoFileDialogViewList
            If .Show <> -1 Then GoTo err_Handler:
            BrowseForFile = fDialog.SelectedItems.Item(1)
        End With
        Exit Function
        BrowseForFile = vbNullString
        Resume lbl_Exit
    End Function

    Graham Mayor - Word MVP

    Tuesday, September 25, 2018 8:35 AM