Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
op_thorsager
368 Views, 2 Replies

Import/replace embedded .xlsx file through form built with iLogic

Hi, I have created a rule inside a simple part drawing that lets you open a filebrowser inside a form. The code looks like this:

'present a File Selection dialog
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.Filter = "Excel Spec Sheet(*.xlsx)|*.xlsx"
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
End If

MessageBox.Show("You selected: " & selectedfile , "iLogic")

at its current stage, the form is very simple, and only includes an image as Banner, and the mentioned code.

op_thorsager_0-1673355838835.png

The form looks as shown above.

 

everything works as inteded, and i know its only displaying an explorer in which you can select a file you want to use. What i want it to do is have it embed the file selected, as the inteded use of the tool im working on, is to have a standardized spreadsheet layout with necessary parameters defined within. The reason why i'm not using a spreadsheet link for this, is due to functionality, as the final product is gonna be used internally on an international scale. 

 

The reason i want it to embed/replace the currently embedded spreadsheet, is so that a non inventor user can fill out the spreadsheet template i've made, send it to one of our engineers, who will then use the form and define the filepath for the received spec sheet. 

what is the most convenient approach to this setup? 

the file you import through the form will define the parameters inside the assembly, and update dimensions accordingly. 

 

My thought would be to have a "default" setup spreadsheet embedded inside the assembly, which functions as a dummy. when our engineer receives a specsheet, or updates a specsheet, they will then use the form to define filepath to the new and updated sheet with new parametric values, but with the same name definitions as the dummy sheet. After selecting the path of the updated specsheet, i want it to replace the currently embedded dummy sheet, but keep the same parameter names, so that it doesn't end up just adding a copy of the already added sheet parameters. 

 

I don't know what would be the best solution to this, or if it's even possible to do what i want it to do. 

Alternatively i guess i could make a spreadsheet setup, which looks identical to an exported XML file from the parameter window inside Inventor - that way would just need to write an iLogic rule which functions as an "import XML" button. 

 

Any recommendations regarding which solution would work in my case? The currently used code does not import anything from the file selected through the form - i'm slowly testing my way through all of this, as i'm very new to all of this iLogic and VB setup. 

 

I hope my description of what i'm trying to do is sufficient. If not, feel free to ask :slightly_smiling_face: