我有这段代码,它可以在另一个模块中完美运行,但是当我将它复制到我现在正在使用的模块时,它会抛出
“错误 1004 方法打开对象工作簿失败”
当"Set TlWb"
我通过对话框输入文件或让程序自己决定时,我不知道为什么,因为它看起来很平庸,而且没有太多可能出错的选项。我很确定我提供给程序的路径是正确的,并且一切都得到了DIM
正确的处理。
这是代码:
'opens open prompt for ABII Parallel Import Tracker - Month/Year.xlsx, on cancel opens actual month
MsgBox "Select ABII Parallel Import Tracker - Month/Year.xlsx file to open. Cancel opens actual month"
With Application.FileDialog(msoFileDialogOpen)
.Show
If .SelectedItems.Count = 1 Then
TlWbPath = .SelectedItems(1)
End If
End With
If TlWbPath <> "" Then
Set TlWb = Workbooks.Open(TlWbPath)
Else: Set TlWb = Workbooks.Open(traceLogPath & "ABII Parallel Import Tracker - " & Format(Date, "mmm-yyyy") & ".xlsx")
End If