Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Curtis_Waguespack
in reply to: Anonymous

Hi @Anonymous,

 

I tested this with Inventor 2017 and Windows 10, Office 365 Excel version 1809, build 10827.20138, and it works as expected.

 

Try this example version of the code, it should give you a couple of messages that might help confirm that the rule is working, one showing the selected excel file, and one showing the resulting iProperty info. If those don't show the results expected then you might post back, and that might give a hint as to what the problem is. 

 

Note too that this example has an Update line at the end, this is needed when working with a title block to "refresh" the sheet and show that the custom iprops have changed, otherwise the drawing doesn't update when the rule has finished, but will on save, etc.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'Browse for the Excel file
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx"
oFileDlg.DialogTitle = "Select a Project Information Excel File"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
'exit if file not selected
MessageBox.Show("Some Error Happened", "iLogic")
Return
ElseIf oFileDlg.FileName <> "" Then
myXLS  = oFileDlg.FileName
MessageBox.Show("Excel File = " & myXLS, "iLogic")
End If

'look at sheet1 of the spreadsheet
GoExcel.Open(myXLS, "Sheet1")


Dim oName As String = GoExcel.CellValue("A1")
iProperties.Value("Custom", oName) = GoExcel.CellValue("B1")
oString = iProperties.Value("Custom", oName)

oName = GoExcel.CellValue("A2")
iProperties.Value("Custom", oName) = GoExcel.CellValue("B2")
oString = oString & " | " & iProperties.Value("Custom", oName)

oName = GoExcel.CellValue("A3")
iProperties.Value("Custom", oName) = GoExcel.CellValue("B3")
oString = oString & " | " & iProperties.Value("Custom", oName)

GoExcel.Close

MessageBox.Show(oString, "iLogic")

InventorVb.DocumentUpdate()