Code worked in 2022 but not in 2023

Code worked in 2022 but not in 2023

AMN3161
Advocate Advocate
422 Views
4 Replies
Message 1 of 5

Code worked in 2022 but not in 2023

AMN3161
Advocate
Advocate

So my company has been using this code I made to automatically pull BOM information, it been working great for years and since we got the 2023 it is some what buggy. This is just a portion of the rule, no point of posting the entire rule. This error can be created when i run this isolated from the but it requires you to have a custom iproperty called "Project_ Excel_File_Name" already created. 

 

If iProperties.Value("Custom", "Project_ Excel_File_Name") = "" Then

MessageBox.Show("I dont have a project Excel BOM linked, please show me where it is", "Project BOM", MessageBoxButtons.OK)

Dim oFileDlg1A As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg1A)
oFileDlg1A.InitialDirectory = oOrigRefName1A
oFileDlg1A.CancelError = True
On Error Resume Next
oFileDlg1A.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg1A.FileName <> "" Then
selectedfile1A = oFileDlg1A.FileName

End If

MessageBox.Show("You selected: " & selectedfile1A, "iLogic")
iProperties.Value("Custom", "Project_ Excel_File_Name") = selectedfile1A

End IF

 

 

Previously, it would pop open a window and i can select a file but now the window only shows folders not  any of the contained files of any file type

 

Is this a Inventor bug or is the code not operation the same in the new inventor?

0 Likes
Accepted solutions (1)
423 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

Maybe the application object  should be "ThisApplication".  This is the sample file dialog I would use. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 5

whashtonjrGV2BR
Explorer
Explorer
Accepted solution

@A.Acheson 

The reference you are pointing to is for VBA, not iLogic (VB.Net based) which is what AMN3161 is referencing. I sometimes catch myself doing that.

Unfortunately, I'm stuck in the past (2018) waiting for my company to get up to speed.

@AMN3161 

However, when I first ran the code, I could select a file (so the folder only view wasn't an issue) but nothing would happen when I selected OK. I added a file type filter (oFileDlg1A.Filter = "Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx") and tried it again and it worked correctly. So likely a different bug in 2018 but worth a try?

 

Add it after the CreateFileDialog.

Dim oFileDlg1A As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg1A)
oFileDlg1A.Filter = "Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx"
oFileDlg1A.InitialDirectory = ThisDoc.Path
oFileDlg1A.CancelError = True

Also check to be sure the VB.Net is current.

Hope this helps!

Regards,

0 Likes
Message 4 of 5

AMN3161
Advocate
Advocate

This fixed my problem, thank you!

0 Likes
Message 5 of 5

A.Acheson
Mentor
Mentor

You are correct. I don't use VBA but because Inventor samples are written in VBA and not VB.NET we unfortunately have to keep referencing the samples we have. Once you know the small differences between the languages it makes writing VB.NET code very easy. One for the idea board I suppose.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes