View Full Version : Retrieving user responses from the open/save dialog box


cliftonx
03-23-2010, 03:52 PM
Hello,

I'm using the following Open/Save Dialog Box function(code excerpt):

Dim strInputFileName As String
Dim strfilter As String
strfilter = ahtAddFilterItem(strfilter, _
"Portable Doument Format (*.pdf)", "*.PDF")
strInputFileName = ahtCommonFileOpenSave(Filter:=strfilter, OpenFile:=False, _
DialogTitle:="Please select a Directory location for your report...", _
FileName:="Traditional Well", _
Flags:=ahtOFN_HIDEREADONLY)

I would like to know, how do I go about retrieving the user's response from the dialog form, using the above fuction(i.e. when the user clicks the Close or Cancel buttons)? Also, is there a way to suppress the Filename and Filetype fields from the dialog form? Since, I'm only interested in knowing the location of where the user wants their report files stored. Subsequent code will name the report files automatically.

Thanks in Advance,

Cliff

SOS
03-23-2010, 03:59 PM
strInputFileName

is what you check.

If they hit cancel it will be "" and if they selected something, the file name and path will be there.

cliftonx
03-24-2010, 06:08 AM
Thanks for your response. In my sample code I'm using a default value for the filename: FileName:="Traditional Well", so when the strInputFileName variable gets returned, the default value will be returned if the user clicks Cancel or Close(which is ok). Wanted to know is there anyway to distinguish when those specific buttons(Cancel or Close) get pushed?

SOS
03-24-2010, 08:01 AM
FileName needs to have the ENTIRE path and file name including file extension.

cliftonx
03-24-2010, 08:08 AM
Thanks SOS, your first suggestion worked. I walked thru the code using the debugger and confirmed that the strInputFileName variable will be "" if you cancel or close the form. The path, directory and filename will be set when the save button is clicked.

Thanks.:)

SOS
03-24-2010, 08:19 AM
Glad we could help.