Inventor 2011
So I'm using a parameter to launch an excel file that this specific Assembly references. It's not embedded.
I need the ability to launch the referenced excel file. I have a parameter called "Launch_Excel" with No and Yes as options.
I need to write it such that, if it detects "Yes", that it launches Excel, and also sets that value back to "No". I can't seem to get it to make this change while the parameter window is open. Do I need to force Inventor to close the parameter window?
Current code:
Format:HTML Format
Version:1.0
StartHTML: 165
EndHTML: 4650
StartFragment: 314
EndFragment: 4618
StartSelection: 314
EndSelection: 314
If Launch_Excel = "Yes" Then
Launch_Excel = "No"
Dim sheetName As String = ring_size
newExcelApp = CreateObject("Excel.Application")
newExcelApp.Visible = True
wb = newExcelApp.Workbooks.Open(IO.Path.Combine("X:\Autodesk\EVR Inventor Reference Files\", "retaining_ring_specs.xlsm"))
wb.Sheets(sheetName).Activate
End If
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
While you are editing the "Launch_Excel" parameter, the parameters dialog will not show value changes to it that are made by the rule. It only shows the changes that you make directly to the cell. This is the way the multi-value list editing control (ComboBox) works within the table of parameters. I will see if we can change it.
The way it is now, if you click in another cell in the parameters dialog, you will see that the Launch_Excel value has changed back to Yes.
Ok... makes sense.
Now, would it be possible to:
open parameters, click "yes" from multi-value to launch excel file.
Clicking Yes causes:
If param="Yes" then
-close parameter window
-set param back to "No"
-open parameter window
-launch excel file
Here's a modified version of your rule to do those steps:
If Launch_Excel = "Yes" Then Dim oControlDef as ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("AppSelectNorthwestArrowCmd") oControlDef.Execute ' start the default command (Select) Launch_Excel = "No" RuleParametersOutput() ' assign the modified value to the parameter right away Dim sheetName As String = ring_size newExcelApp = CreateObject("Excel.Application") newExcelApp.Visible = True wb = newExcelApp.Workbooks.Open(IO.Path.Combine("X:\Autodesk\EVR Inventor Reference Files\", "retaining_ring_specs.xlsm")) wb.Sheets(sheetName).Activate oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppParametersCmd") oControlDef.Execute ' start the Parameters command End If