Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Using OutputTo

Reply  
Thread Tools
maxx_eclipse's Avatar
Computer Specs
Member with 286 posts.
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
03-Feb-2010, 11:55 AM #1
Using OutputTo
Afternoon everyone,

Just wanted to ask a question (which I hope is simple enough to answer).

I'm using VBA to run the DoCmd.OutputTo action to save a file. I would like the default save location to be the desktop, but unfortunately, the location of the desktop is unique for each computer*, so to determine the save location for the desktop wouldn't be so easy by just entering a default path.

Any ideas?

Thanks!

* I know this is the case for Vista, but I can't remember if it's the same for XP.... In fact, would it be possible to use a code that determines whether they're running a Vista or XP and then through that determine the save location?
IMM's Avatar
IMM IMM is offline IMM is authorized to help remove malware.
Malware Removal Specialist with 3,260 posts.
 
Join Date: Feb 2002
04-Feb-2010, 09:20 PM #2
You could locate what you want by using special folders as in
http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

some various other language variations of it (there are lots out there)
http://msdn.microsoft.com/en-us/libr...xe(VS.85).aspx
http://msdn.microsoft.com/en-us/libr...xe(VS.85).aspx


Or, you might simply want to use %HOMEDRIVE%%HOMEPATH%\Desktop\ plus, of course, the file name in the Outputfile argument.
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
04-Feb-2010, 11:09 PM #3
Here is some VBA to get the desktop path.

Code:
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(&H10&)
strMyDesk = objFolder.Self.Path
MsgBox strMyDesk
Regards,
Rollin
maxx_eclipse's Avatar
Computer Specs
Member with 286 posts.
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
05-Feb-2010, 12:20 AM #4
Well, thanks for your help all,

but it seems that DoCmd.OutputTo doesn't like "%HOMEDRIVE%%HOMEPATH%\Desktop\" or "strMyDesk"...

Any other ways?
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
05-Feb-2010, 09:44 AM #5
Please post the entire line of code you are attempting to use for the export.

Regards,
Rollin
maxx_eclipse's Avatar
Computer Specs
Member with 286 posts.
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
05-Feb-2010, 11:42 AM #6
DoCmd.OpenForm "XLS", acNormal, "", "(([CONTACTS].[Select])=-1)", , acNormal
MsgBox "You will now be prompted to select the output folder for the .xls file.", vbInformation, "Select Output Folder"
DoCmd.OutputTo acOutputForm, "", "Excel97-Excel2003Workbook(*.xls)", "", True, "", 0, acExportQualityPrint
MsgBox "The selected records have been successfully exported into an Excel Document (.xls)." & vbCrLf & vbCrLf & "The XLS file will now open.", vbInformation, "Successful Export"
DoCmd.Close , ""
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:20 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.