我试图通过从一个单元格中获取值并连接所需的文件名来打开工作表,但它显示错误:对象变量或未设置的块变量 我使用以下代码: 在哪里" 123.xlsx"是我要打开的工作簿的名称。
Dim output_path As Workbook
dim xlwkbrpt1 as workbook
output_path = Application.ActiveWorkbook.ActiveSheet.Range("F14").Value
Set xlwkbrpt1 = xlApp.Workbooks.Open(output_path & "\" & "123.xlsx")
答案 0 :(得分:1)
您声明变量output_path
的类型错误。试试这个:
Dim output_path As String
Dim xlwkbrpt1 As Workbook
output_path = Application.ActiveWorkbook.ActiveSheet.Range("F14").Value
Set xlwkbrpt1 = Workbooks.Open(output_path & "\" & "123.xls")