Syntax to combine transfer spreadsheet & Openfilesave API

  • Thread starter Thread starter Hugh self taught
  • Start date Start date
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
 
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.
 
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.
 
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?
 
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?
 
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:="Please select file...", _
Flags:=ahtOFN_HIDEREADONLY, _
FileName:="Competitors.xls")
 
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:="Please select file...", _
Flags:=ahtOFN_HIDEREADONLY, _
FileName:="Competitors.xls")
 
Thanks Doug, That's what I was missing. All works as I wanted now.
 
Thanks Doug, That's what I was missing. All works as I wanted now.
 

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

Back
Top