I am using Inventor 2022 and VBA in it. I tryed to save file with VBA script (macro - button).
Here is the code, which is included in documentation of old version of Inventor but it include some errors:
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)
Source: https://github.com/ADN-DevTech/Inventor-Training-Material (common Inventor Functions the powerpoint presentation)
All of my solutions are not correct!
I think this is the rewrited code from object browser but not in Inventor library:
Inventor.FileSaveAs.AddFileToSave(oDoc, "C:\myTemp\t.ipt")
I found also someting like this:
Inventor.FileSaveAs.AddFileToSave := oDoc, "C:\myTemp\t.ipt"
Thank you for any help.
CodePudding user response:
Hello and welcome to the SO
Your first code fragment is OK. It expects the document was not saved before or you want to save document as new file on disk.
Later you can use just oDoc.Save()
for simple save document. If you call this save method and the document was not saved before, standard save file dialog is displayed to the user.
Your next two code fragments are not useable in Inventor, because this is from ApprenticeServer
.