Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using default file locations in VBA programming

I need to save an excel workbook in the default location for the user logged
onto the machine.

For example.
C:\Documents and Settings\username\My Documents
where username varies with different users and machines

I understand there are some shortcuts to these locations but cannot seem to
locate them in the documentation.
I am thinking something like this should work.

dim MydocumentsDir as string
mydocumentsDir = ?????????????

I then plan to add additional info like filename and a subdirectory to the
string.
and save my data in that folder.

Just cannot seem to find the code to replace the ??????????????

Gary M.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using default file locations in VBA programming


This may help you towards your goal :-
'-------------------------------------
Sub RetrieveLogonName()
Dim wshNetwork As Object
Dim LogonName As Variant
Set wshNetwork = CreateObject("WScript.Network")
LogonName = wshNetwork.UserName
MsgBox LogonName
End Sub
'-------------------------------------

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using default file locations in VBA programming

Brian

You got me started down the right path.

This is what wound up using.

Sub Desktop_Path()
Dim WSHShell As Object
Set WSHShell = CreateObject("WScript.Shell")
Dim DesktopPath As String

' Read desktop path using WshSpecialFolders object
DesktopPath = WSHShell.SpecialFolders("Desktop")
Debug.Print DesktopPath

DesktopPath = WSHShell.SpecialFolders("Mydocuments")
Debug.Print DesktopPath

Set WSHShell = Nothing

End Sub

hope you might find it usefull.

Thanks,
Gary m.



"BrianB" wrote in message
...

This may help you towards your goal :-
'-------------------------------------
Sub RetrieveLogonName()
Dim wshNetwork As Object
Dim LogonName As Variant
Set wshNetwork = CreateObject("WScript.Network")
LogonName = wshNetwork.UserName
MsgBox LogonName
End Sub
'--------------------------------------


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
default file locations Excel 2007 Machin8409 Setting up and Configuration of Excel 1 January 26th 10 12:44 PM
Macro File Locations Lori-Wheaten Excel Discussion (Misc queries) 2 June 9th 08 05:56 PM
file locations Pam[_2_] Setting up and Configuration of Excel 0 August 10th 07 03:20 PM
Moving file locations Derek Links and Linking in Excel 1 August 9th 06 12:45 AM
external data file locations Lou Sanderson Excel Discussion (Misc queries) 4 April 26th 06 05:17 PM


All times are GMT +1. The time now is 05:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"