1. Kevin Dinh
  2. PowerBuilder
  3. Friday, 4 December 2020 23:01 PM UTC

Hello Everyone,

I am trying to use the function GetFileSaveName() to open a folder and would like to default the Excel12 extension (*.xlsx).  But I have no luck.

Any suggestions?

Thanks,

Kevin

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Saturday, 5 December 2020 18:10 PM UTC
  2. PowerBuilder
  3. # 1

If you want xlsx to appear as default in the dropdownlistbox, then simply list it as the first item in the list.

string ls_path
int li_rc

// example 1: open only one file:
string ls_oneFile
// The 4th parameter is the default extension This is ONLY doing something if you have selected "All Files (*.*)" 
// and then write a filename without an extension.
li_rc = GetFileSaveName ( "Save As ...", ls_path, ls_oneFile, "XLSX", "Excel Files (*.xlsx),*.xlsx, Word Documents (*.docx),*docx, All Files (*.*),*.*", "", 32770)


// example 2: more than one file:
// use ctrl or shift to select more than one file
string ls_FileList[]
li_rc = GetFileSaveName ( "Save As ...", ls_path, ls_FileList, "XLSX", "Excel Files (*.xlsx),*.xlsx, Word Documents (*.docx),*docx, All Files (*.*),*.*", "", 32770)

 

Now I'm not sure if you want to see *.xlsx also in the Filename field, if that's what you want then assign something like this to the ls_path variable (mind that you have to use a really existing folder, not c:\temp2 probably ):
ls_path = "C:\temp2\*.xlsx" // this will make "*.xlsx" appear in the "filename"

Also, be aware, that if you then don't switch to another folder when choosing / writing the filename, the ls_path parameter with still have the "*.xlsx" at the end, so if you are going to use it, you have to strip that off after selecting the filename. If you do switch to another folder the *.xlsx won't be there anymore.

string ls_path
int li_rc

// example 1: open only one file:
string ls_oneFile
ls_path = "C:\temp2\*.xlsx" // this will make "*.xlsx" appear in the "filename"

// The 4th parameter is the default extension This is ONLY doing something if you have selected "All Files (*.*)" 
// and then write a filename without an extension.
li_rc = GetFileSaveName ( "Save As ...", ls_path, ls_oneFile, "XLSX", "Excel Files (*.xlsx),*.xlsx, Word Documents (*.docx),*docx, All Files (*.*),*.*", "", 32770)

// example 2: open more than one file:
// use ctrl or shift to select more than one file:
string ls_FileList[]
ls_path = "C:\temp2\*.xlsx"
li_rc = GetFileSaveName ( "Save As ...", ls_path, ls_FileList, "XLSX", "Excel Files (*.xlsx),*.xlsx, Word Documents (*.docx),*docx, All Files (*.*),*.*", "", 32770)
li_rc = li_rc // for debug

 

See the PB help on "GetFileOpenName" to get more information (like on the flag parameter which determines how your dialog will look like and which controls it might display or not).

regards

Comment
  1. Kevin Dinh
  2. Monday, 7 December 2020 17:33 PM UTC
@Miguel - Thank You very much. Very appreciated.

I didn't put the Excel Files (*.xlsx) as the first item on the list. That was the problem.

Happy Holidays to you and family!
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 7 December 2020 17:39 PM UTC
Glad it worked...same go you Kevin!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.