引用带有变量的工作簿

时间:2019-09-03 14:10:31

标签: excel vba variables reference

我尝试保存然后打开相同的工作簿,但是出现“下标超出范围”错误。我找不到打开和设置工作簿中带有变量的变量的任何解决方案。

我拒绝了FN之类的新变量,但无法解决。我该如何解决?

WeekNum = Format(Date, "ww")
path1 = "W_"
path2 = "Haftalik_Sonuclar.xlsm"
FN = path1 & WeekNum & path2
ActiveWorkbook.SaveCopyAs ("Z:\07_SUPPLY_CHAIN\07-G B\PG\W_" & WeekNum & "Haftalik_Sonuclar.xlsm")
ActiveWorkbook.Close
Workbooks(FN).Open
Dim wb1 As Workbook: Set wb1 = Workbooks(Filename)

“下标超出范围”

1 个答案:

答案 0 :(得分:0)

The syntax of Workbooks.Open方法:

expression.Open FileName

所以,使用

workbooks.open "Z:\07_SUPPLY_CHAIN\07-G B\PG\W_" & WeekNum & "Haftalik_Sonuclar.xlsm"

不是

Workbooks(FN).Open