直接在Word中使用插入>插入图片选项时,插入图片对话框“所有图片”文件名下拉筛选器包含文件扩展名.svg。
使用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有没有办法让.svg文件的扩展名显示为过滤器的一部分,使用VBA插入图片对话框?
这发生在Microsoft Office365 ProPlus Version 1908 (Build 11929.20562即点即用)中。
发布于 2020-12-09 07:45:28
这里有一些变通方法代码供您尝试。
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 Subhttps://stackoverflow.com/questions/65207126
复制相似问题