下面的代碼片段旨在打開特定XL文件的特定工作表並使其成爲活動工作表。但是,debug.print提供了不同工作表的輸出。 objws.activate
不應該使活動工作表成爲對象嗎?worksheet.activate未激活
Dim XLApp As New Excel.Application
Dim ObjXL As Excel.Workbook
Dim ObjWS As Excel.Worksheet
Set ObjXL = XLApp.Workbooks.Open(TargetXL)
Set ObjWS = ObjXL.Worksheets(TargetWS)
ObjWS.Activate
Debug.Print ObjWS.Application.ActiveSheet.Name & "," & ObjWS.Name