打开vbe-工具-引用-Microsoft Excel 11.0 Object Library 添加以下代码: Private Sub GetRange() On Error Resume Next Dim excelApp As Excel.Application Set excelApp = GetObject(, "Excel.Application") If Err Then MsgBox Err.Description Exit Sub End If excelApp.Visible = True Dim myRange As Range Set myRange = excelApp.ActiveSheet.Range("a1:c2") End Sub
要求先打开excel。 |