工作簿打开,但我仍然得到一个VBA下标超出范围的错误 [英] Workbook opens but I still get a VBA Subscript out of range error
问题描述
我试图通过我的marco脚本打开工作簿,每次尝试打开一个工作簿时,我都会重复出现此错误。我遇到的问题是当我使用
Workbooks.Open(strFilePath)
其中,
strFilePath =genericfilepath \FileDuplicate.xlsx
该脚本启动该工作簿,但我仍然得到一个下标超出范围错误。我也尝试通过将代码放在$ / $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
。
Workbooks.Open(strFilePath)
。
。
Application.DisplayAlerts = True
我也尝试过错误恢复下一步无效,该工作簿启动,但我仍然会得到一个流行错误的msg。
如果要使用vba打开的工作簿,您需要设置
引用它,像这样
Dim wb as工作簿
设置wb = Workbooks.Open(路径和文件名的字符串)
然后你可以继续参考 Workbook
对象 wb
并使用其方法并参考其属性。
I'm trying to open a workbook through my marco script and I have this error recurring everytime I try to open a workbook. The problem I'm facing is that when I use
Workbooks.Open (strFilePath)
where,
strFilePath = "genericfilepath\FileDuplicate.xlsx"
The script launches the workbook but I still get a Subscript out of range error. I've also tried to turn of alerts by putting my code in between
Application.DisplayAlerts = False
.
.
Workbooks.Open (strFilePath)
.
.
Application.DisplayAlerts = True
I've also tried On Error Resume Next to no avail, the workbook launches but I still get a pop error msg.
If you want to use a workbook opened with vba, you need to Set
a reference to it, like so
Dim wb as Workbook
Set wb = Workbooks.Open(string of path and filename)
Then you can go on referencing the Workbook
object, wb
and use its methods and refer to its properties.
这篇关于工作簿打开,但我仍然得到一个VBA下标超出范围的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!