LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get save file as dialog?

Hi,
  I want to copy the file and save it as another the file using Save As file dialog box. So I searched this forum and found this artical. But the activeX control used in this vi. i.e.MSComDlg.ICommonDialog could not be loaded in my system(as shown when I open the vi, downloaded from above link). What might be reason for it? Or does NI provide any other method/vi to display Save As file dialog.
 
Thanks in advance.
 
Regards:-
Mike
0 Kudos
Message 1 of 6
(7,299 Views)
Hi Mike,

why don't you use the Standard "File Dialog.vi"?

Just use it twice (once for the path/filename of the file to be copied
and once for the new name) and wire those to the standard "copy.vi".

Oliver
0 Kudos
Message 2 of 6
(7,282 Views)
Hi Oliver,
   Thanks for the suggestion. I try to use "File Dialog.vi" in my application. It's working as I expected. But one problem with it is that when Save As dialog box open Save Type As combo box (which is below the File Name box) shows All Files as default. Even if we provid Pattern(all files) input parameter to this vi as .csv file it still shows All Files in Save Type As combo box. So if user select All Files in combo box and saves it then it will not save as .csv file. I want to avoid this so that my file will be stored as .csv file always.
   In short is it possible to remove All Files option from Save Type As combobox so that always it will display .csv as file type? It will be very helpful to me.
 
Thanks again.
 
Regards:-
Mike
0 Kudos
Message 3 of 6
(7,251 Views)
Could you post the vi?
I don't have any problems if I test this and the csv-pattern is displayed as you want it to.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 4 of 6
(7,248 Views)

Hi Becktho,

          Thanks for the interest you have shown in my problem. I am herewith attaching the vi I used to copy the file. In Save As dialog box you will see the Save As Type box with "Comma Seperated Excel File(*.csv)" as default option. If user does not change this option and save the file then it will work absolutly fine. But if user selects "All File(*.*)" option (which is below the "Comma Seperated Excel File(*.csv)" option)  in Save type as box and save the file It will not save as .csv file(I am not able to get the file extention of it). And such file will not open in excel by simply clicking it. You have to change the extention of it.to .csv 

  So how can I force the user to save the file as .csv file.

 

Thanks:-

Mike

0 Kudos
Message 5 of 6
(7,244 Views)
You can not force the user to enter a "defined" file name. If you use the standard file dialog, you can always get an "invalid" result.
 
To solve your problems, I have two solutions in mind.
 
1. If you keep the file dialog, you have to check the resulting path for its ending. According to this check either add ".csv" or replace the ending with ".csv". Because if the user enters "filename.txt" in the filename control, the file has ".txt" ad ending.
 
2. You could also create a special file dialog on your own with a path control to browse to an existing directory and a string control to enter a filename. You can set the pathcontrol to just browse for a directory. The input of the string control can be checked for anything - so for instance you could check if there are blanks in the filename or if the user entered an ending. Then you could notify the user via messagebox to enter a valid filename. The ending can be added automatically, so you always have a .csv ending.
 
 
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 6 of 6
(7,239 Views)