根据我所读到的内容,我相信我对下面的代码有一个不合格的参考问题。我认为我需要做的是具体参考工作簿,但是我尝试了很多方法,但都没有成功。有人能帮忙吗?
Dim f As FileDialog, str As String
Set f = Application.FileDialog(msoFileDialogFilePicker)
f.Show
str = f.SelectedItems(1)
Dim xl As Excel.Application
Set xl = New Excel.Application
xl.Visible = True
xl.Workbooks.Open (str)
Dim wsT As Worksheet, wsA As Worksheet, wsE As Worksheet, wsI As Worksheet, lr As Long, lrow As Long
Worksheets.Add(After:=Worksheets(1)).Name = "TABLE"
Set wsA = Worksheets("ACTIVE")
Set wsT = Worksheets("TABLE")
我尝试过的一个例子是
Set wb = xl.workbooks.open(str)
谢谢!
答案 0 :(得分:1)
你快到了。只需先定义变量即可。
Dim xl As Excel.Application
Set xl = New Excel.Application
xl.Visible = True
Dim xlWB as Excel.Workbook '** added this line
Set xlWB = xl.Workbooks.Open(str)
其余代码乍一看看起来不错