我想列出文件夹中的每个文件名(.wav文件)并创建一个超链接。类似下图:
我发现了这段代码,但我无法对其进行调整。
Dim MyPath As String
Dim MyName As String
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With
If Len(MyPath) = 0 Then Exit Sub
If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Selection.TypeText Text:=MyName & " "
Selection.InlineShapes.AddPicture "C:\loudspeaker.jpg", True, True
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=MyName, TextToDisplay:=myImage & vbCr
Selection.InsertAfter MyName & " "
MyName = Dir
Loop
Selection.Collapse wdCollapseEnd
End Sub