Save As Pop-Up (API or Procedure?)

  • Thread starter Thread starter John
  • Start date Start date
J

John

My form uses a query the user can view on the screen, Print to a report, or
save as an Excel file. I woud like a "Pop-Up" window to come up just like
the "File", "Save As" option on any windows program to allow the user to
browse to where they would like to put the file, type in a name, and click
the "Save" button. I found (on this forum) a great solution for a user to
browse out to select a file to import, this would be the same only the othr
way...
 
My form uses a query the user can view on the screen, Print to a report, or
save as an Excel file.  I woud like a "Pop-Up" window to come up just like
the "File", "Save As" option on any windows program to allow the user to
browse to where they would like to put the file, type in a name, and click
the "Save" button.  I found (on this forum) a great solution for a userto
browse out to select a file to import, this would be the same only the othr
way...

use the OpenSaveFile API at Access Web.
http://www.mvps.org/access/api/api0001.htm

Then use TransferSpreadsheet to transfer the data...
 
(e-mail address removed),

Thanks for the feedback. Just one other question. I got the module
working, but when I run the code, the pop-up has "Open" for the button to
click, and there is an "open read only" checkbox on the screen. It clearly
is formted as the "Save" dialog box. It is working ok, but would be
confusing to the users. Any way to change the "Open" to "Save"?

After creating the module, here's the code I am using:

Function Save_FileName() As String
Dim strFilter As String
'Dim lngFlags As Long (doesn't look like this is used any more...)
Dim SaveFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.XLS")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
Save_FileName = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=ahtOFN_OVERWRITEPROMPT Or
ahtOFN_READONLY, _
DialogTitle:="Save file to...")
End Function
 
You missed the second example on that page.

Save_FileName = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=ahtOFN_OVERWRITEPROMPT Or
ahtOFN_READONLY, _
OpenFile:=False, DialogTitle:="Save file to...")

(Yeah, I know the default for a boolean is False, but Ken explicitly sets
OpenFile to True if it's not passed to ahtCommonFileOpenSave)
 
Doug,

After much searching through all the long and odd veriable names, I found my
errors. You were absoulty correct. I missed two things, "OpenFile:=False"
and "ahtOFN_HIDEREADONLY". The first changes the "Open" button to "Save" and
the second removes the "Open Read Only" checkbox. So the final code was:

Function Save_FileName() As String
Dim strFilter As String
'Dim lngFlags As Long
Dim SaveFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.XLS")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
Save_FileName = ahtCommonFileOpenSave( _
OpenFile:=False, InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=ahtOFN_OVERWRITEPROMPT Or
ahtOFN_HIDEREADONLY, _
DialogTitle:="Save file to...")
End Function


Of course you know all this - so this is for newbies like me that find the
code. Enjoy!

Thanks again...
 
Back
Top