我有两个非常有用的VBA项目开始引起问题,一个用于对列表/一批文件执行各种任务,另一个用于将图形的元素输出到另一个文件。
两个VBA脚本都运行良好,并按照预期执行,但是在完成并退出时,我在命令行上收到以下错误:
“\n ***内部错误:VL命名空间不匹配\n”“类型Y重置:
关于可能导致此问题的任何想法? 我怀疑这与打开并在绘图之间切换的代码有关,就像我在待办事项列表中没有任何文件的情况下运行批处理VBA一样,它不会生成错误,但是当我在调试器中单步执行代码时,只有在代码完成时才会弹出错误。
这是一个代码片段,它实际上打开并调用批处理项目中的图纸上的函数,周围还有其他我认为不相关的废话:
-
- Dim oDWG As AcadDocument
- For i = 0 To Me.FilesToOpList.ListCount - 1
- BatchLaunchWin.Statusbox.Text = "Processing file " & CStr(i + 1) & " of " & BatchLaunchWin.FilesToOpList.ListCount
- DoEvents
- Set oDWG = Application.Documents.Open(Me.FilesToOpList.List(i, 1), ReadOnly)
- DwgChanged = False
-
- '##########################################do stuff here#########################################
- 'Example function below, there are actually several..
- If BatchLaunchWin.SearchChkBox Then
- BatchLaunchWin.Statusbox.Text = "Changing Text.."
- DoEvents
- DwgChanged = ChangeText(oDWG, BatchLaunchWin.SearchTextBox.Value, BatchLaunchWin.ReplaceTextBox.Value)
- End If
-
-
- If ReadOnly Then
- oDWG.Close False
- Else
- oDWG.Close 'This will fail if the file is inadvertantly opened read only
- End If
-
- 'emergency stop routine exits here
- If CrashStop Then Exit For
-
- Next i 'next drawing to process
这是来自导出VBA的代码片段:
- Dim ExportedDwg As AcadDocument
- SubjectDwg.Wblock ExportPath & "Backboxes" & ExpBoxName, BoxSSet
- Report = Report & "Backbox file (flush) created with " & CStr(BoxSSet.Count) & " entities." & vbCrLf
- 'open and saveas earlier filetype
- Set ExportedDwg = SubjectDwg.Application.Documents.Open(ExportPath & "Backboxes" & ExpBoxName, False)
- ExportedDwg.Activate
- ExportedDwg.SaveAs ExportedDwg.FullName, ac2007_dwg
- ExportedDwg.Close False
在一个理想的世界里,我会用 VB.NET 重写代码,但我现在没有时间, 能够快速对批处理例程进行“每个会话”调整,而不必重新编译等,这真是太好了。
谁能对此有所了解?它在Acad 2015上运行,据我所知,我们在2013年没有这个问题。
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |