VB Code to Disable / Bypass Update Prompt at File Open

VB Code to Disable / Bypass Update Prompt at File Open

Anonymous
Not applicable
1,772 Views
3 Replies
Message 1 of 4

VB Code to Disable / Bypass Update Prompt at File Open

Anonymous
Not applicable

Using Inventor 2012, I am writing VB code that opens, updates, changes parameters, and saves and closes a file. 

 

My process so far opens one file, updates the parameters, saves, then opens the assembly file linked to the previous file to update, save, and close.  The trouble I'm having is when I open the second file, Inventor prompts me to update the assembly, and won't do anything until I click yes (see attachment).  Is there a way to either disable this prompt, or add VB code that would click YES everytime to update the file?  Or perhaps a setting within Inventor that automatically saves and updates when you open instead of doing it in VB code?

 

Similarly, when the assembly file closes, it asks if I want to save it AND all the parts included in the assembly.  I want it to click YES everytime to make sure it saves. 

 

Through a web search, I found the .DisplayAlerts = True/False line, but it does not appear to work in my code

(i.e. if I use  _invApp.DisplayAlerts = False). 

 

My code for opening the second file (the .iam file) is basic and simplistic, as I am still new to this and learning.

 

        _invApp.Documents.Open("filename.iam")

        _invApp.ActiveDocument.Update()

        _invApp.ActiveDocument.Save()

 

Thanks for reading all this and thanks in advance!

0 Likes
Accepted solutions (1)
1,773 Views
3 Replies
Replies (3)
Message 2 of 4

ekinsb
Alumni
Alumni
Accepted solution

Try the Application.SilentOperation.  When this property is set to True all dialogs should be suppressed.  A default answer has been defined for all dialogs and when this is True the default will be used.  You'll probably need to test it a bit to verify that the default is what you want, but it typically is.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 4

Anonymous
Not applicable

That worked!  Thanks so much!

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hello,

 

I'm facing the same issue.

I've created a part and and assembly. The assembly is linked to the part (= the parameters are in the part and the assembly get these).

Through an Userform VBA I would like, at the same time, to update the part (I've done) and the assembly and the related .idw.

 

Could you kindly share your code,

Alberto

0 Likes