Syntax to combine transfer spreadsheet & Openfilesave API

H

Hugh self taught

Hi,

I have the following which is incomplete & I need some assistance with it. I
want to export table "Competitors" to a spreadsheet called "Competitors" but
I want to select where I save it. I'd prefer it if the name was automatically
populated in the save filename field to enforce consistancy.

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
'strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:="Please select file...", _
Flags:=ahtOFN_HIDEREADONLY)

DoCmd.TransferSpreadsheet acExport, 8, Competitors, (strFilter \
"Competitors.xls"), True
 
K

Ken Snell MVP

See my website for example code (your code is incomplete):

Browse to a single EXCEL File and Import Data from that EXCEL File via
TransferSpreadsheet
http://www.accessmvp.com/KDSnell/EXCEL_ImpExp.htm#ImpBrowseFile

Note that the above code example is for importing, but you can use it for
exporting by changing the first argument of the DoCmd.TransferSpreadsheet
action from acImport to acExport.
 
K

Ken Snell MVP

See my website for example code (your code is incomplete):

Browse to a single EXCEL File and Import Data from that EXCEL File via
TransferSpreadsheet
http://www.accessmvp.com/KDSnell/EXCEL_ImpExp.htm#ImpBrowseFile

Note that the above code example is for importing, but you can use it for
exporting by changing the first argument of the DoCmd.TransferSpreadsheet
action from acImport to acExport.
 
H

Hugh self taught

Thanks Ken, I've got that working great. Now the other part of my post was
whether or not the file name could be automated for convenience & consistancy?
 
H

Hugh self taught

Thanks Ken, I've got that working great. Now the other part of my post was
whether or not the file name could be automated for convenience & consistancy?
 
D

Douglas J. Steele

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:="Please select file...", _
Flags:=ahtOFN_HIDEREADONLY, _
FileName:="Competitors.xls")
 
D

Douglas J. Steele

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:="Please select file...", _
Flags:=ahtOFN_HIDEREADONLY, _
FileName:="Competitors.xls")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top