0

我在其中使用 Inventor 2022 和 VBA。我尝试使用 VBA 脚本(宏 - 按钮)保存文件。

这是代码,它包含在旧版本 Inventor 的文档中,但包含一些错误:

Dim oDoc As PartDocument

Rem this causes the "Invalid character _"
oDoc = _InvApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject)

Rem this causes the "Expected: ="
oDoc.SaveAs("C:\Temp\SaveTest.ipt", False)

来源:https ://github.com/ADN-DevTech/Inventor-Training-Material (常见的Inventor Functions powerpoint演示)

我所有的解决方案都不正确!

我认为这是来自对象浏览器的重写代码,但不在Inventor 库中:

Inventor.FileSaveAs.AddFileToSave(oDoc, "C:\myTemp\t.ipt")

我还发现了这样的东西:

Inventor.FileSaveAs.AddFileToSave := oDoc, "C:\myTemp\t.ipt"

感谢您的任何帮助。

4

1 回答 1

0

您好,欢迎来到 SO

你的第一个代码片段是好的。它预计该文档之前未保存,或者您希望将文档另存为磁盘上的新文件。

稍后您可以仅oDoc.Save()用于简单的保存文档。如果您调用此保存方法并且之前未保存文档,则会向用户显示标准保存文件对话框。

您接下来的两个代码片段在 Inventor 中不可用,因为它来自ApprenticeServer.

于 2021-11-04T17:44:20.293 回答