On Error Resume Next
Set ExcelApp = GetObject(, "Excel.application")
If Err Then
Err.Clear
Set ExcelApp = CreateObject("Excel.application")
If Err Then
MsgBox ("不能运行Excel,请检查是否安装了Excel")
Exit Sub
End If
ExcelApp.Application.Visible = True
ExcelApp.Workbooks.Add
End If
ExcelApp.StatusBar = "Ready"
End Sub
参考里面要引用excel object library vbcad 发表于 2017-8-15 19:23
Dim MyPath As String, MyName As String
Dim objExcel As Object, objBook As Object, objSheet As Objec ...
Public Sub 导材料实验()
Dim MyPath As String
Dim objExcel As Object, objBook As Object
Dim objSheet As Excel.Workbook
Set objExcel = CreateObject("Excel.Application") '建立EXCEL对象
MyPath = Dir(ThisDrawing.Path & "\*.xls") ' 指定路径为当前脚本目录。
Do While MyPath <> "" ' 开始循环。
Set objSheet = Workbooks.Open(ThisWorkbook.Path & "\" & MyPath)
Set objBook = objExcel.Workbooks.Open(FilePath) '打开表格文件
MyPath = Dir ' 查找下一个
Loop
End Sub
我用的你的程序,稍作修改做的,运行到Dim objSheet As Excel.Workbook
提示用户类型未定义 906379829 发表于 2017-8-16 15:57
Public Sub 导材料实验()
Dim MyPath As String
Dim objExcel As Object, objBook As Object
参考里面要引用excel object library mikewolf2k 发表于 2017-8-16 16:02
参考里面要引用excel object library
明白了,就是引用栏里添加excel 不知道打开后关闭excel怎么写,我只想读取数据,但是打开excel后屏幕上看不到cad图形
页:
1
[2]