transferspreadsheet

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
 
K

Ken Snell

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
 
J

jpkeller55

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)
 
K

Ken Snell

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!
 

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