0

When using the Insert > Insert Pictures option directly in Word the Insert Picture dialog "All Pictures" File name dropdown filter contains the file extension .svg.

Insert Picture Dialog

When using VBA to display the dialog, the "All Pictures" File name dropdown filter does not contain the file extension .svg:

Set oDialog = Dialogs(wdDialogInsertPicture)
 
 ' Work with dialog
With oDialog

     ' Display the dialog
    .Display
     
     ' Insert InlineShape if the Name property (Filepath) <> ""
    If .Name <> "" Then
        ActiveDocument.InlineShapes.AddPicture FileName:=.Name, _
        LinkToFile:=False, _
        SaveWithDocument:=True, _
        Range:=Selection.Range
    End If
End With

VBA Insert Picture Dialog

Is there a way to get the .svg file extension to display as part of the filter using the VBA Insert Picture Dialog?

This occurs in Microsoft Office 365 ProPlus Version 1908 (Build 11929.20562 Click-to-Run).

BigBen
  • 46,229
  • 7
  • 24
  • 40
Debbie
  • 1
  • 2
    It's a bug. No known workaround, sorry. To report it, choose File>Feedback>Send a Frown and describe the problem, including the code. If you set up a page with screenshots of both dropdowns, you can include a screenshot. I've already sent a report. – John Korchok Dec 08 '20 at 22:41
  • I think it's more like a relatively new feature that just hasn't been completely implemented yet with the VBA Object Model. The same problem occurs when trying to [`Export` a graphic as .svg](https://stackoverflow.com/q/65131924/12287457). For exporting I found a workaround but it was a [disproportionally huge effort](https://stackoverflow.com/a/65212838/12287457). – GWD Dec 09 '20 at 09:36

1 Answers1

0

Here's some workaround code for you to try.

Sub InsertPicture()
    With Application.FileDialog(msoFileDialogFilePicker)
        .Title = "Select the image file to insert. Multiple selections not allowed."
        .InitialFileName = "What Ever"
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "All Pictures", "*.emf; *.wmf; *.jpg; *.jpeg; *.jfif; *.jpe; *.png; *.bmg; *.dib; *.rle; *.gif; *.emz; *.wmz; *.pcz; *.tif; *.tiff; *.svg; *.cgm; *.pct; *.pict; *.wpg", 1
        If .Show = 0 Then
            Exit Sub
        End If
        If .SelectedItems(1) <> "" Then
            ActiveDocument.InlineShapes.AddPicture FileName:=.SelectedItems(1), _
            LinkToFile:=False, _
            SaveWithDocument:=True, _
            Range:=Selection.Range
        End If
    End With
End Sub
Rich Michaels
  • 1,663
  • 2
  • 12
  • 18