Private Sub Command1_Click() On Error Resume Next Dim dwgname As String dwgname = "c:\Test.dwg" '测试用,事先画一张Test.dwg If Dir(dwgname) <> "" Then Dim acadApp As AcadApplication Set acadApp = GetObject(, "AutoCAD.Application.14") '原先测试时是(,"AutoCAD.Application"),程序可以运行 If Err Then Err.Clear Set acadApp = CreateObject("AutoCAD.Application.14") If Err Then MsgBox Err.Description Exit Sub End If End If
Dim acadDoc As AcadDocuments Set acadDoc = acadApp.Documents acadDoc.Open (dwgname) acadApp.Visible = True acadApp.ZoomExtents Else MsgBox "文件" & dwgname & "不存在," End If End Sub
原程序在第7行时是Set acadApp = GetObject(, "AutoCAD.Application"),该程序可以通过AutoCAD2002打开图纸Test.dwg,现因某些原因需要通过AutoCAD R14来打开图纸。(系统中装有CAD2002和CAD-R14) ,但做了相应更改后,程序报错:类型不匹配!请问这是什么原因??