Hi,
I'm testing that under 2013 SP1.1 Update 2 and it seems to work correctly:
Public Sub CreateFileDialog() Dim App As Inventor.Application Set App = ThisApplication Dim dlg As FileDialog Call App.CreateFileDialog(dlg) dlg.InitialDirectory = "C:\" dlg.filter = "Inventor Files (*.ipt)|*.ipt | Assembly File (*.iam)|*.iam" dlg.DialogTitle = "Save Native" dlg.ShowSave End Sub
Regards,
Philippe.
Doesn´t work for me in C# & when I copy paste your code directly in the VBA editor & run I end up in my vault project folder.. e.g. not C:\". I´m on the same build.
Hi,
there is a C# demo code in the API help reference. Hope it helps you to figure out the problem:
public void TestFileDialog() { Application oApp = ThisApplication; // Create a new FileDialog object. FileDialog oFileDlg; oApp.CreateFileDialog(out(oFileDlg)); // Define the filter to select part and assembly files or any file. oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"; // Define the part and assembly files filter to be the default filter. oFileDlg.FilterIndex = 1; // Set the title for the dialog. oFileDlg.DialogTitle = "Open File Test"; // Set the initial directory that will be displayed in the dialog. oFileDlg.InitialDirectory = "C:/Temp"; // Set the flag so an error will not be raised if the user clicks the Cancel button. oFileDlg.CancelError = false; // Show the open dialog. The same procedure is also used for the Save dialog. // The commented code can be used for the Save dialog. oFileDlg.ShowOpen(); // oFileDlg.ShowSave(); System.Windows.Forms.MessageBox.Show("File " + oFileDlg.FileName + " was selected.", "Selected file"); }
Yep.. That´s more or less the same code I used, but no cigar as mentioned earlier, Using the IV2009 workaround described in this thread, does the job so I´m long gone. I have a strong feeling the internal vaultclient is overriding oFileDlg.InitialDirectory.. Check it out 😉
Workaround described in this thread doesn't work for an open file dialog. Anybody got a work around for an open file dialog? or an alternative method of calling an open file dialog box where the initial directory can be set??
Thx in advance
Hi ZX_Spectrum_48k ,
could you clarify what kind of problem you hit? I did not get a clue from the existing messages in the thread.
Hi,
The sample code in the 2014 help menu as reproduced below will not produce a file dialog box starting in c:\temp, instead the file dialog will display the last used folder.
Seems to have been an issue for a while ......................
Public Sub TestFileDialog() ' Create a new FileDialog object. Dim oFileDlg As FileDialog Call ThisApplication.CreateFileDialog(oFileDlg) ' Define the filter to select part and assembly files or any file. oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*" ' Define the part and assembly files filter to be the default filter. oFileDlg.FilterIndex = 1 ' Set the title for the dialog. oFileDlg.DialogTitle = "Open File Test" ' Set the initial directory that will be displayed in the dialog. oFileDlg.InitialDirectory = "C:\Temp" ' Set the flag so an error will be raised if the user clicks the Cancel button. oFileDlg.CancelError = True ' Show the open dialog. The same procedure is also used for the Save dialog. ' The commented code can be used for the Save dialog. On Error Resume Next oFileDlg.ShowOpen ' oFileDlg.ShowSave ' If an error was raised, the user clicked cancel, otherwise display the filename. If Err Then MsgBox "User cancelled out of dialog" ElseIf oFileDlg.FileName <> "" Then MsgBox "File " & oFileDlg.FileName & " was selected." End If End Sub
Hi,
Strange. It seems to work for me and starts in whatever folder I set as InitialDirectory: http://www.screencast.com/t/w2K7yJ9q
Cheers,
*Make sure the directory actually exists and you have proper permissions*
Don't think thats the problem - I can get initial directory to behave if I have no inventor files open.
As soon as I have an inventor file open, always get the project folder regardless of what initial directory is set to.
Anyone else find the same thing??
We have the same problem in all 4 seats of Inventor Pro 2014.
oFileDlg.InitialDirectory settings are not honoured and the dialog opens with Workspace in focus. We have Vault 2014 Workgroup installed and signed in.
When the dialog opens in the Project Folder, if we browse to another directory from the dialog box and cancel the dialog or open the file, next time initialdirectory is set to the other directory we browsed to or opened file from.