运行VBA脚本时出现运行时错误432

问题描述 投票:0回答:1

我尝试在 Autocad 中运行 VBA 脚本,但收到以下错误:“自动化错误 - 未找到元素”单击“调试”会突出显示此行: 设置 xlbook = GetObject("C:�9 -LB-06 MX-sv.xlsx") 我可以看到该文件存在于文件夹中。

Public acad As Object
Public acadapp As AcadApplication, AcadDoc As AcadDocument
Public doc As Object
Public ms As Object
Public ss As Object
Public ssnew As Object
Public ssnew2 As Object
Public Theatts As Variant
Public Theatts2 As Variant
Public MsgBoxResp As Integer

Private Sub CommandButton1_Click()
Dim BlkG(0) As Integer
Dim ro As Integer
Dim TheBlock(0) As Variant
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
Dim insertionPnt(0 To 2) As Double
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
'Set xlbook = GetObject("C:\07509\04-LB-06 MX-sv.xlsx")
Set xlbook = GetObject("C:\07509\04-LB-06MX-SV.xlsx")
Set xlSheet = xlbook.Sheets("04-LB-06 MX")
Set xlapp = xlbook.Parent
xlapp.DisplayAlerts = False

'set reference to workbook

ro = 2
'declare local variables

 Dim dwgName As String
 Dim vtag As String
 'vtag = "c:\07509\" & sh.Cells(ro, 5) & ".dwg"
 Debug.Print vtag
 
testflZS
 
xlbook.Close savechanges:=False
'save the changes in Excel

xlapp.Quit
'quit Excel
 
Set xlSheet = Nothing
Set xlbook = Nothing
Set axlapp = Nothing
'clean up

ThisDrawing.Save
ThisDrawing.Close
xlapp.DisplayAlerts = True
End Sub
Private Sub CommandButton3_Click()
Dim BlkG(0) As Integer
Dim ro As Integer
Dim ssnew As Object
Dim TheBlock(0) As Variant
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
Dim insertionPnt(0 To 2) As Double
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlbook = GetObject("C:\07509\04-LB-06 MX-sv.xlsx")
Set xlSheet = xlbook.Sheets("04-LB-06 MX")
Set xlapp = xlbook.Parent
xlapp.DisplayAlerts = False
'set reference to workbook

我尝试运行该脚本,我希望它生成一些 Autocad 绘图。

excel vba autocad
1个回答
0
投票

修复安装“Microsoft 365 Apps for Enterprise”后,我不再遇到该错误。

© www.soinside.com 2019 - 2024. All rights reserved.