【发布时间】:2014-12-17 16:26:14
【问题描述】:
我的错误编号为 1004:
Function getWorksheet(SheetNumber As Integer) As Worksheet
Dim workbook As workbook
Dim file As Variant
file = ShowFileDialogAndFindFile
Set workbook = Workbooks.Open(file, True, True)
getWorksheet = workbook.Worksheets(SheetNumber)
End Function
Function ShowFileDialogAndFindFile() As Variant
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
ShowFileDialog = vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With
Set fd = Nothing
End Function
我正在从另一个模块调用:
Dim sheetExtern As Worksheet
sheetExtern = getWorksheet(1)
【问题讨论】: