gpt4 book ai didi

excel - 按路径和名称引用工作簿 - VBA

转载 作者:行者123 更新时间:2023-12-02 00:44:44 25 4
gpt4 key购买 nike

Sub Quack()

Dim LookupWB As Workbook
Set LookupWB = Application.Workbooks("C:\Users\user1\Desktop\Book1.xlsx")

End Sub

此代码出现错误:

Subscript out of range I think it's because of the "Set" line. How do you correctly reference a workbook by path?

如果我写:Set LookupWB = Application.Workbooks("Book1.xlsx")(没有完整路径)它可以完美工作。非常感谢!

最佳答案

我认为您需要先使用Open功能:

Workbooks.Open Filename:="C:\Users\user1\Desktop\Book1.xlsx"
Set LookupWB = Application.Workbooks("Book1.xlsx")

关于excel - 按路径和名称引用工作簿 - VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13751610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com