1. John Vanleeuwe
  2. PowerBuilder
  3. Tuesday, 31 March 2020 04:59 AM UTC

Hi all,

On PB2017 how can we achieve the following.

 

1) we are using the dw_1.SaveAs() function to allow our users to export to the built-in formats supported by PB (excel ,html and so on. 

The saveas() is only giving us a 0 or 1 return code. How can we retrieve the filename and folders the user choose in which he wants the file to be saved ? 

 

2) the SaveAs pops up the built-in file/folder selection dialog box. But to me this looks rather dated compared to the one windows is using these days ? Any idea on how to get a more recent look & feel to this dialog box please ?

 

 

TIA

John

 

René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 05:53 AM UTC
  2. PowerBuilder
  3. # 1

Hi John,

The easiest way: Use the GetFileSaveName function to show a dialog to specify the filename. So you know the path and filename and this dialog is better. After that call the SaveAs function and specify the filename and depending on file extension the saveas type.

 

Example:

IF GetFileSaveName ("Export", ls_path, ls_file, "XLSX", &
  "Excel-File (*.XLSX),*.xlsx,PDF-File (*.PDF),*.pdf", "", &
  2 ^ 1 /* Explorer */ &
  + 2 ^ 6 /* NoChangeDir */ &
  + 2 ^ 13 /* Overwriteprompt */ ) <> 1 THEN return
IF Lower (Right (ls_path, 5)) = ".xlsx" THEN
  dw_report.SaveAs (ls_path, XLSX!, TRUE)
ELSEIF Lower (Right (ls_path, 4)) = ".pdf" THEN
  dw_report.SaveAs (ls_path, PDF!, TRUE) <> 1
ELSE
  MessageBox("Warning", "Unexpected File Extension!")
END IF

 

Comment
  1. John Vanleeuwe
  2. Tuesday, 31 March 2020 06:19 AM UTC
Hi Rene,



thanks , but this requires the user to already know the extension or type the extension , i want to give him all possiblities available. our users sometimes dont have a clue about what an extension is or





TIA

John
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 31 March 2020 14:13 PM UTC
Hi John;

Then I would suggest that you design your own SaveAS Dialogue specific to this exact required functionality.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Eduardo G. Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 08:17 AM UTC
  2. PowerBuilder
  3. # 2

Well you can always design a dialog box to your taste and your needs, also it is not necessary that the user knows the extension of a file should only know where you want to save ... excel, pdf, text, etc. the rest is up to you.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 31 March 2020 13:31 PM UTC
  2. PowerBuilder
  3. # 3

Hi, John -

I suggest you look at Roland Smith's "GetFileName" free code sample program on his TopWizProgramming web site:

https://www.topwizprogramming.com/freecode_getfilename.html

This uses Windows API functions to display a much more robust and contemporary File Open/File Save dialog window. You can define the list of file extensions listed and include all of the selections that the dw.SaveAs() function provides, or provide only the ones your user community understand and use...Once the user has identified the path, name and type of file (extension), you can pass this information to the dw.SaveAs() method and it will save the data in the requested format without displaying its dialog window.

Regards, John

Comment
There are no comments made yet.
John Vanleeuwe Accepted Answer Pending Moderation
  1. Friday, 3 April 2020 03:42 AM UTC
  2. PowerBuilder
  3. # 4

Thanks all for your comments and feedback ! Guess we will have to roll our own with the help of Rolands lib.

Comment
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Saturday, 16 July 2022 02:06 AM UTC
  2. PowerBuilder
  3. # 5

Hi all,

I know this thread is old, but thought I'd go ahead and put my in my 2 cents instead of create a new thread... The dw_1.SaveAs works fine for me, but the Help File says the function returns 1 or -1.  The return code I'm getting is 0 ...  

~~~Tracy

Comment
  1. Daryl Foster
  2. Tuesday, 19 July 2022 04:33 AM UTC
Hi Tracy, this post by John Fauss https://community.appeon.com/index.php/qna/q-a/q-a-forum-tip-including-source-code-in-your-question shows how to add formatting to a reply. You need to add it as a reply rather than a comment, but it makes things so much easier to read.
  1. Helpful
  1. Tracy Lamb
  2. Wednesday, 20 July 2022 15:17 PM UTC
Thanks Daryl! I thought I could add formatting to a reply, didn't realize it doesn't work on comments.

  1. Helpful
  1. Tracy Lamb
  2. Wednesday, 20 July 2022 15:23 PM UTC
P.S. Fixed the flakey loop from the code I shared earlier. Was trying to do too many things at once... so I moved some code to more appropriate places (different events and functions), and just re-designed the basic logic.
  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.