打开多个工作簿并激活特定的工作簿

时间:2018-12-10 22:00:44

标签: excel vba worksheet

我有多个工作簿,而我只是想激活一个特定的工作簿并不断出现错误,指出"object doesnt support this property or method."

以下代码:

Sub RUNME()

'Call OPENFiles 'this call runs a small piece of code to open all the files an works fine


Dim wbmacro As Workbook
Dim wblean As Workbook
Dim wbmain As Workbook

Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet


Set wbmacro = Workbooks.Item("MacroFile.xlsm")
Set wbmain = Workbooks.Item("Mainfile.csv")
Set wblean = Workbooks.Item("Secondfile.csv")

Set ws1 = wbmacro.Worksheets.Item("Data")
Set ws3 = wblean.Worksheets.Item("Sheet2")

wblean.ws3.Activate 'line with error

我尝试了几种不同的方式玩游戏,但不明白为什么会出现此错误?

0 个答案:

没有答案