【问题标题】:When displaying Insert Picture dialog, the "All Pictures" File name filter does not contain .svg file extension显示“插入图片”对话框时,“所有图片”文件名过滤器不包含 .svg 文件扩展名
【发布时间】:2021-03-20 06:12:30
【问题描述】:

直接在 Word 中使用“插入”>“插入图片”选项时,“插入图片”对话框“所有图片”文件名下拉过滤器包含文件扩展名 .svg。

Insert Picture Dialog

使用 VBA 显示对话框时,“所有图片”文件名下拉过滤器不包含文件扩展名 .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

有没有办法让 .svg 文件扩展名显示为使用 VBA 插入图片对话框的过滤器的一部分?

这发生在 Microsoft Office 365 ProPlus 版本 1908(内部版本 11929.20562 即点即用)中。

【问题讨论】:

  • 这是一个错误。没有已知的解决方法,抱歉。要报告它,请选择 File>Feedback>Send a Frown 并描述问题,包括代码。如果您设置的页面包含两个下拉菜单的屏幕截图,则可以包含屏幕截图。我已经发送了报告。
  • 我认为它更像是一个相对较新的功能,只是尚未完全使用 VBA 对象模型实现。尝试Export a graphic as .svg 时也会出现同样的问题。对于导出,我找到了一种解决方法,但它是 disproportionally huge effort

标签: vba image svg ms-word insert


【解决方案1】:

这里有一些解决方法代码供您尝试。

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

【讨论】:

    猜你喜欢
    • 2019-07-20
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    相关资源
    最近更新 更多