所以我有这行VBA代码:
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""283669 (2)"";Extended Properties=""""" _, Destination:=Range("$B$3")).QueryTable
我打算在该行代码中使用用户声明的变量“ Krs”。
以下代码似乎无效:
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:="OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""&Krs&"";Extended Properties=""""", Destination:=Range("$B$3")).QueryTable
以下任何一项:
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=""OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location="""&Krs&""";Extended Properties=""""", Destination:=Range("$B$3")").QueryTable
我希望我的问题来自错误地使用引号Mars,但是我无法查明错误的出处。
答案 0 :(得分:0)
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:="OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""" & Krs & """;Extended Properties=""""", Destination:=Range("$B$3")).QueryTable