transferspreadsheet

  • Thread starter Thread starter jpkeller55
  • Start date Start date
J

jpkeller55

Easy VBA question for somebody who knows what they are doing (unlik
me).

I would like to put a command button on a form that will export th
data of a query to an excel file and possible ask the user for the fil
name.

Thanks
 
Here is one way to do this (there are other variations on this theme):

DoCmd.TransferSpreadsheet
acExport,acSpreadsheetTypeExcel9,"QueryName",InputBox("Enter path and
filename:")

If you want to open the "navigation" window and let the user browse to the
actual filename, you might try using the code shown at The ACCESS Web:
http://www.mvps.org/access/api/api0001.htm
 
Ken, I get the following error message when I attempt to incorporate th
code (see below) to open the windows file browser:

Compile error:
Sub or Function not defined

the term "ahtAddFilterItem" is highligted


Any ideas?

Thanks, Jim

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)"
"*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
 
You forgot to include the VBA code that is just below the code snippet that
you are trying to use. That entire VBA code (in smaller font size) also must
be used!
 
Back
Top