Using a Radio Box to Open Specific Excel Sheets

Using a Radio Box to Open Specific Excel Sheets

Anonymous
Not applicable
838 Views
5 Replies
Message 1 of 6

Using a Radio Box to Open Specific Excel Sheets

Anonymous
Not applicable

Hello,

 

In my ever-evolving quest to create a logical drawing template, I was wondering how (if possible) an iLogic rule could be used to open a specific sheet in an excel document, using the input from a radio box?

 

Thanks.

0 Likes
Accepted solutions (1)
839 Views
5 Replies
Replies (5)
Message 2 of 6

asiteur
Collaborator
Collaborator

Hi,

 

You could make a rule like this:

iProperties.Value("Summary", "Title")=GoExcel.CellValue("filename.xls", "Sheet1", "A2")

Read Excel and store that into (Custom)Properties that you use some how, the title block for example.

Then you can make a form with radio buttons on which sheets to use for example.

 

I can help you further when you provide some more detail!



Alexander Siteur
Project Engineer at MARIN | NL
LinkedIn

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Alexander,

 

What I'm basically getting at is that the radio box would be to choose whether the CNC operation would be a contour cut or a waterjet operation.  When the rule is fired, the user would choose from the radio box the aforementioned options, and then upon hitting OK, would call up an excel file containing CNC program numbers, either landing on the "contour" or "waterjet" sheet.  The user can pull a number and implement it into the drawing.

 

This would save the user all the trouble of having to trace to the file location each and every time one has to pull numbers.

 

Does this help?

0 Likes
Message 4 of 6

asiteur
Collaborator
Collaborator

Hi there,

 

I coudn't expect that you wanted to really open an Excel window.

 

Well, what you surely can do is: when you know which cell you want to access get the value to Inventor, as a parameter as simple message as text on a drawing, as a property... This you can quite simply do with iLogic. You can specify the cell you want to see as directly or do someting like "where column name= and rowname=..."

 

If for any reason you really want to see the excel sheet opened.... you probably can do something, maybe in VBA, surely with VB.net ... but that's not so very straightforward, will take you a good couple of hours provided you already have some solid programming experience.

 

The radiobutton part is actually quite simple, in iLogic you can put a multivalue list behind it. Then if variable1="case1" myexcelsheetpath="....xls"

 

Hope this helps.



Alexander Siteur
Project Engineer at MARIN | NL
LinkedIn

0 Likes
Message 5 of 6

MechMachineMan
Advisor
Advisor
Accepted solution

Tweak lines as required for the appropriate sheets/excel file name.

 

Good luck!

 

Sub Main()
	Dim xlApp As Object
	Dim xlwb As Object
	Dim xlws As Object
	Dim xlFileName As String
	Dim xlSheetName As String
	Dim resp As Boolean
	
	xlFileName = "C:\Users\Owner\Desktop\TEST.xlsx"
	
	resp = InputRadioBox("Choose the Operation to perform to this part", "Contour", "Waterjet", True, Title := "CNC Type")
		
	If resp = True 'ie; contour was selected
		xlSheetName = "CONTOUR"
	Else
		xlSheetName = "WATERJET"
	End If
	
	xlApp = GetObject("", "Excel.Application")
	xlApp.Visible = True
	
	xlwb = xlApp.Workbooks.Open(xlFileName)
	Try
		xlws = xlwb.Worksheets(xlSheetName)
		xlws.Activate

		AppActivate("Microsoft Excel")
	Catch
		MsgBox("Sheet of the name " & vbLf & xlSheetName & vbLf & "not found!" & vbLf & vbLf & "Aborting!",, "MechMachineMan iLogic")
	End Try
	
	xlwb = Nothing
	xlApp = Nothing
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 6

Anonymous
Not applicable

Excellent, that's exactly what I'm looking for.  Thanks MM.

0 Likes