0
我不是一个好的程序员,所以所有的帮助是值得欢迎的。微软Word vba宏插入文件链接到一个文件
我想创建一个简单的脚本。当我插入图像时,我想自动添加链接到文件的选项。
我创建了一个脚本,但问题是我需要在Word插入它之前选择文件两次(它实际上只添加一个文件)。 任何想法我做错了什么?
Sub InsertLinkToFile()
'
' InsertLinkToFile Macro
'
'
Dim strPicName As String
Dim vShape As InlineShape
With Application.FileDialog(msoFileDialogFilePicker) 'Dialogs(wdDialogInsertPicture)
.AllowMultiSelect = False
.Title = "Select the File that you want to insert"
.Show
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.png", 1
FiletoInsert = .SelectedItems(1)
If .Show = -1 Then
strPicName = .SelectedItems(1)
With ActiveDocument
Set vShape = .InlineShapes.AddPicture(FileName:=strPicName, LinkToFile:=True, SaveWithDocument:=False)
End With
End If
End With
End Sub
你有两行以'.Show' - 刚落,第一个。 –