我想将工作簿设置为维度。该工作簿已被定义为字符串。但是,当我将此字符串设置为“ wb”时,出现类型不匹配错误...
当前行是:
Dim History as String
History = "Filename.xlsx"
Dim wb As Workbook
Set wb = History
有什么想法吗?
答案 0 :(得分:1)
这是方法:
Dim History as String
History = "Filename.xlsx"
Dim wb As Workbook
Set wb = Workbooks(History)
答案 1 :(得分:0)
Tim的解决方案假定FileName.xlsx
已打开。如果不是,则:
Sub TomHolland()
Dim History As String
History = "Filename.xlsx"
Workbooks.Open "C:\TestFolder\" & History
Dim wb As Workbook
Set wb = ActiveWorkbook
End Sub
或类似的东西