File Dialog Initial Directory stuck on workspace

File Dialog Initial Directory stuck on workspace

yvandelafontaine
Advocate Advocate
4,302 Views
13 Replies
Message 1 of 14

File Dialog Initial Directory stuck on workspace

yvandelafontaine
Advocate
Advocate

For Some Reason when I try to force a specific path in a file open dialog, inventor point toward the workspace every time

 

any reason or solution?

 

Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)


oFileDlg.InitialDirectory = "C:\"
oFileDlg.CancelError = True
oFileDlg.Filter = "Excel Files (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm"
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")
Accepted solutions (1)
4,303 Views
13 Replies
Replies (13)
Message 2 of 14

BrandonBG
Collaborator
Collaborator

I didn't verify this, but does your project (*.ipj) show "C:\" as a Frequently Used Subfolder or the Workspace folder?

 

Brandon

0 Likes
Message 3 of 14

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi yvandelafontaine,

 

FileDialog.InitialDirectory is ignored if assembly or part is open. Inventor engineering team knows about this issue.


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 14

pball
Mentor
Mentor

@chandra.shekar.g

 

I just ran into the same issue and created a thread about it before seeing this one. There are a few more details also, like the file name property also does not work.

 

https://forums.autodesk.com/t5/inventor-customization/inventor-open-file-dialog-bug-vba-vb-net/td-p/...

 

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 5 of 14

RoyWickrama_RWEI
Advisor
Advisor

I was trying hard to save the files in a different folder without success. Finally, I saw this information. Having got to do with iLogic, it is unfair that we can't save files in a different logical place.

 

I appreciate if someone helps to override the file save location as shown in the code below (can't save in the location required)

 

 

Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)

oFileDlg.InitialDirectory = "C:\$WF_DHAMAG\Libs_DHAMAG\RL001 FASTENERS\Assemblies\Reserve List\New Folder\"

oLocation = "C:\$WF_DHAMAG\Libs_DHAMAG\RL001 FASTENERS\Assemblies\Reserve List\"

oFileDlg.FileName = "RECT.idw"
oFileDlg.CancelError = False
'On Error Resume Next
oFileDlg.ShowSave()
If Err.Number <> 0 Then
MessageBox.Show("File not SAVED.", "Dialog Cancellation")
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
MessageBox.Show("File " & selectedfile & " was selected.", "Dialog Selection Made")
End If
0 Likes
Message 6 of 14

JarFu
Autodesk
Autodesk

The problem gone from Inventor 2018, I checked with Inventor 2016~2019 and the issue could not reproduced with Inventor 2018.3 (build 284). Could you please double confirm if you're still annoy by this problem? Many thanks!



Jar Fu
SW Engineer
Inventor QA
Autodesk, Inc.
0 Likes
Message 7 of 14

bshbsh
Collaborator
Collaborator

I am having this problem on 2018.3.6 and using VBA, can not set either initialfolder nor filename on a open file dialog.

0 Likes
Message 8 of 14

pball
Mentor
Mentor

2020.1 here and below are my finding on this. Seems partially fixed in my opinion, unless this is how someone intended it to work in which case I'd disagree with that.

 

open file dialog

initial directory works

file name does not work

 

save file dialog

initial directory does not work

file name works

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 9 of 14

hwu
Advocate
Advocate

My Inventor is 2020 and I need my save as dialog directory to be the file location first, then maybe go different place. However, it leads me to the previous saving location, otherwise, it will be perfect for me.

 

Regards,

0 Likes
Message 10 of 14

CadUser46
Collaborator
Collaborator

Just stumbled across this in 2019.4.  FileOpen > FileName does not work.


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

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 11 of 14

thomas.fitzgerald
Alumni
Alumni

Using Inventor 2021 and InitialDirectory does not work with ShowSave()

Thomas Fitzgerald

Principal Implementation Consultant
0 Likes
Message 12 of 14

thaleFUWKH
Observer
Observer

I am using Inventor 2022. You can set the initial directory but it is ignored when using ".ShowSave()"

The work around is to set the the .FileName with the full path.

 

'set the directory to open the dialog at
oFileDlg.InitialDirectory = ThisDoc.Path 'This sets the parameter but it is ignored in ".ShowSave()"
'set the file name string to use in the input box (set full path to get Initial Directory to work)
oFileDlg.FileName = ThisDoc.Path + "\" + ThisDoc.FileName(False) 'This works
'oFileDlg.FileName = ThisDoc.FileName(False) 'This does not work

'work with an error created by the user backing out of the save
oFileDlg.CancelError = True
On Error Resume Next
'specify the file dialog as a save dialog (rather than a open dialog)
oFileDlg.ShowSave()
'oFileDlg.ShowOpen()

Hope this helps others 

Message 13 of 14

d.turksemaFYBBN
Explorer
Explorer
Thanks! This work around did the job for me.
0 Likes
Message 14 of 14

charles4L34S
Contributor
Contributor
InitialDirectory still isn't in Inventor 2024, however your workaround is working perfectly, thanks.