我试图在Excel中打开Word文档,以便将大量信息转储到其中。我使用以下代码:
'Declare a variable as a FileDialog object and create a FileDialog object as a File Picker dialog box
Dim iFileSelect As FileDialog
Set iFileSelect = Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path of each selected item
Dim vrtSelectedItem As Variant
'Use the Show method to display the File Picker dialog box
'The user pressed the action button
If iFileSelect.Show = -1 Then
For Each vrtSelectedItem In iFileSelect.SelectedItems
'vrtSelectedItem contains path of each selected item
MsgBox "The path is: " & vrtSelectedItem
Next vrtSelectedItem
End If
'Set object variable to Nothing
Set iFileSelect = Nothing
我有以下问题:
答案 0 :(得分:0)
如果您在Excel中打开了工作簿,则可以使用其FollowHyperlink方法打开文档。
Sub OpenDoc()
Dim iFileSelect As FileDialog
Set iFileSelect = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
If iFileSelect.Show = -1 Then
For Each vrtSelectedItem In iFileSelect.SelectedItems
ActiveWorkbook.FollowHyperlink vrtSelectedItem
Next vrtSelectedItem
End If
Set iFileSelect = Nothing
End Sub