Save Dialog Box

Save Dialog Box

Anonymous
Not applicable
492 Views
7 Replies
Message 1 of 8

Save Dialog Box

Anonymous
Not applicable
When using the below VB Code:

Sub SetActiveDocument()
Dim inventorApp As Inventor.Application
Set inventorApp = GetObject(, "Inventor.Application")

Call inventorApp.Documents.Open("C:\KCI Vault\KCI Jobs\Automated Beam Clamp\Main Assembly\XXXXMBCA-500.iam", True)
Dim aDoc As Document
Set aDoc = inventorApp.ActiveDocument
aDoc.Update
aDoc.Save

End Sub

After I reach aDoc.Save I get a dialog box that asks if I want to save changes to "XXXXMBCA-500.iam" and its dependents?

Is there a way to turn this dialog box off or fill out the required info through VB??? so I can continue with code THANKS
0 Likes
493 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

Try using the SilentOperation property. 
Something like this:

 

inventorApp.SilentOperation = True

aDoc.Save

inventorApp.SilentOperation = False

 

One other thing.  You don't need to use the
ActiveDocument property to set the document after you've opened.  The Open
method returns the document just opened. 

 

Dim aDoc As Document

aDoc =
InventorApp.Documents.Open("C:\Temp\Part1.ipt", True)
--
Brian
Ekins
Autodesk Inventor API Product Designer

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
When
using the below VB Code: Sub SetActiveDocument() Dim inventorApp As
Inventor.Application Set inventorApp = GetObject(, "Inventor.Application")
Call inventorApp.Documents.Open("C:\KCI Vault\KCI Jobs\Automated Beam
Clamp\Main Assembly\XXXXMBCA-500.iam", True) Dim aDoc As Document Set aDoc =
inventorApp.ActiveDocument aDoc.Update aDoc.Save End Sub After I reach
aDoc.Save I get a dialog box that asks if I want to save changes to
"XXXXMBCA-500.iam" and its dependents? Is there a way to turn this dialog box
off or fill out the required info through VB??? so I can continue with code
THANKS
0 Likes
Message 3 of 8

Anonymous
Not applicable
That worked perfect thanks, and true I don't have to set aDoc as the active document, but I am testing code right now I am going to add to this. I have another question. If I have multiple files open is there a better way of setting one of those files to the active document other than using the Call inventorApp.Documents.Open("FILEPATHANDNAME") again to set it as the active document??

Again Thanks I am new to Inventor VB and I am struggling.
0 Likes
Message 4 of 8

Anonymous
Not applicable

Using the Open method probably isn't a bad way to
get what you want.  Here are a couple of other approaches.  If you
already have a reference to the document you want to activate you can do
this:

 

oDoc.Activate

 

If you don't have a reference and know it's open
you can do this:

 

oDoc =
Documents.Item("FILEPATHANDNAME")

oDoc.Activate
--
Brian Ekins
Autodesk
Inventor API Product Designer

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine

 
0 Likes
Message 5 of 8

Anonymous
Not applicable
Below is my modified code and the silent operation works wonderful. I am now having trouble with it updating. If I step through the code it has no problem but if I run the code the update doesn't happen. I also have to save the active workbook twice before it will do anything as well. Any Suggestions???

Sub SetActiveDocument()
ActiveWorkbook.Save
ActiveWorkbook.Save

Dim inventorApp As Inventor.Application
Set inventorApp = GetObject(, "Inventor.Application")
Call inventorApp.Documents.Open("C:\KCI Vault\KCI Jobs\Automated Beam Clamp\Main Assembly\XXXXMBCA-500.iam", True)
Dim aDoc As Document
Set aDoc = inventorApp.ActiveDocument

aDoc.Update

inventorApp.SilentOperation = True
aDoc.Save
inventorApp.SilentOperation = False

End Sub
0 Likes
Message 6 of 8

Anonymous
Not applicable

I think it should work.  Can you put together
a simple case that demonstrates the problem so I can understand your specific
case?
--
Brian Ekins
Autodesk Inventor API Product Designer

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine
0 Likes
Message 7 of 8

Anonymous
Not applicable
What I do is open all models, and drawings associated with a particular spreadsheet. I then save the workbook, set the assembly as active in Inventor,update it and save it. Everything works when I step through the program using F8, but when I run the program the assembly still shows that it needs to be updated. I have a work around but its kinda of annoying. I put a message box right before I activate the assembly. It works fine with the message box, update is greyed out and the assembly is showing correctly. I tried delays and Doevents, but no luck the only thing that has worked is the annoying message box.

I don't know if this matters but I am running Inventor 08 and XP64 bit. If you still do not understand whats going on let me know and I will send you my models and spreadsheet. Its just weird that it doesn't update theres no errors in the code, plus it activates and saves. Just frustrating.
0 Likes
Message 8 of 8

Anonymous
Not applicable

I'll need an example to reproduce the
problem.  If you can trim the test case down as much as possible that will
help me a lot.  You can send it directly to me at
href="mailto:brian.ekins@autodesk.com">brian.ekins@autodesk.com

--

Brian Ekins
Autodesk Inventor API Product Designer

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine
0 Likes