[Webinar] Streamline your web hosting managementRegister Today


MSAccess How to prompt in export to Excel VBA statement

Posted on 2010-03-31
Medium Priority
Last Modified: 2013-11-27
Capricorn1 gave me the answer for VBA code to export a query to Excel.  Now I'd like to know how to make that query prompt for file name rather than hard-coded as in his answer: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"queryName", "C:\myQuery.xls", True, ""
Question by:Greg989
  • 2
  • 2
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 2000 total points
ID: 29224796

you can use a value typed in a textbox

if len(Me.textboxName & "")>0 then

       DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"queryName", Me.textboxName, True, ""
         msgbox "please enter full path"
          exit sub
end if

Author Comment

ID: 29225703
That is helpful for future reference but what I'd really like to emulate is what happens when you run an OutputTo macro where the file name is left blank.  In that case you are presented the windows "Save As" dialogue screen defaulting to MyDocuments.
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 2000 total points
ID: 29227977

Author Comment

ID: 29229238
Thanks... It appears this will work.  Regardless, it most likely will serve me well for future reference.  Since it is fairly complex, relative to my puny mind, I think I'll just "RunMacro" instead and leave the file name blank as mentioned in my original question.  Thanks!

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question