0

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.

1
  • I edited my post for bugs in Inventor VBA. Commented Nov 5, 2021 at 14:14

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I do not know why, but the oDoc.Save does not work. There is no declaration of object. This causes the "invalid use of property" : oDoc=InvApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject)
I used the oDoc = ThisApplication.ThisDocumet and the Call oDoc.Save() it is from link
Thank you for your efforts, it took me a long time to find a solution to this problem, so it was appropriate to write here.
If you want to export as .obj file use only Call oDoc.SaveAs("C:\myTemp\a.obj", True)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.