Can anybody help?
I am trying to automatically save an inventor document (ipt, idw or iam) using a VBA macro.
here is my code so far....
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then Exit Sub
oDoc.Save
But Inventor keeps crashing every time I run the macro.
What is wrong?
Many thanks in advance!!!!
IsoCAM
In the past I have used...
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
oDoc.Save 'Save.
Testing your code in Invent 2013 didn't crash it.
However there something to note, if the document is a new document and you call the Save method on it as you are doing it should display the dialog prompt for a filename. But if somewhere before this point you have SilentOperation set to true, [ThisApplication.SilentOperation = True], then it will display an error message.
Can somebody test the following code?
Sub savepart()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
oDoc.Save 'Save.
End Sub
I think it does not work!!!!
Please help???
Regards
Darren
Darren,
Your code works only for the document which is previously saved.
This does not work for new document.
Check the earlier comments...
Hi,
Did you actually try the code?
The part is existing. Running the code does not update the file.
Please try the code and see what I mean.
Regards
Darren
Yes i did try your code...
I get Save Dialog for new document.
If the document is already saved then it saves sucessfully
I tried the code too and also get the Save As dialog. That is by design and is the same behavior you see interactively in Inventor. The first time you save a document the Save As dialog appears so you can specify the location and file name to create. Saving after that doesn't display a dialog but just performs the save to the existing document.
To save a new document using the API and bypassing the dialog you need to use the Document.SaveAs method. The first argument is the file name and the second argument should be False, indicating you are doing a Save As rather than a Save Copy As.
You can check to see if a document has been saved by checking the Document.FullFilename. If this returns an empty string then the document has never been saved.
you need to use something like this
Call oDrawDoc.SaveAs("c:\temp\test.idw", False)
it works fine then, hope its wat you are looking for