《ECEL [VBA]从其他工作簿取值.docx》由会员分享,可在线阅读,更多相关《ECEL [VBA]从其他工作簿取值.docx(2页珍藏版)》请在三一办公上搜索。
ECEL VBA从其他工作簿取值法1:Sub Silent_open1Dim myApp As New Application, wkSht As Worksheet隐藏ExcelmyApp.Visible = False打开数据文件,并指定工作表对象Set wkSht = myApp.Workbooks.Open(ThisWorkbook.Path & 8-1.xls).Sheets(1)A1 = wkSht.A1关闭ExcelmyApp.QuitSet wkSht = NothingSet myApp = NothingEnd Sub法2:Sub Silent_Open2Dim myObj As Object GetObject 返回工作表对象的引用Set myObj = GetObject(ThisWorkbook.Path & 8-1.xls)A2 = myObj.Sheets(1).Cells(2, 1)关闭工作簿myObj.CloseSet myObj = NothingEnd Sub