Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Getting the user profile folder

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 15 Jan 2006 02:00 GMT
Hi

I need to get the signature folder for the current folder such as;
"F:\Documents and Settings\Dave\Application Data\Microsoft\Signatures\"
except that instead of Dave I need the correct name for the current user, s
that my code works generically regardless of who is logged in. Is there a
way to do that?

Thanks

Regards
Jay Freedman - 15 Jan 2006 03:18 GMT
>Hi
>
[quoted text clipped - 7 lines]
>
>Regards

One way is to assume the User Templates folder hasn't been changed
from the default, and grab the first part of the path from there:

   Dim SigPath As String
   If InStr(LCase(Options.DefaultFilePath(wdUserTemplatesPath)), _
       "application data") > 0 Then
       SigPath = Replace(LCase(Options.DefaultFilePath( _
           wdUserTemplatesPath)), _
           "templates", "signatures")
   Else
       ' display your favorite folder browser
   End If

An even less-often changed folder is the Startup folder that defaults
at ...\Microsoft\Word\Startup, and which is represented by the
constant wdStartupPath.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
John - 15 Jan 2006 03:27 GMT
Oooh, assumptions could be dangerous. I know I change them for at least one
client to pick up from the server drive the standard company templates.

Anything that is safer?

Regards

>>Hi
>>
[quoted text clipped - 32 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
Paulwh80 - 30 Mar 2006 20:34 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Regards

Hi,
Wouldn't "F:\Documents and
Settings\"&application.username&"\Application
Data\Microsoft\Signatures\" work for you?

Paul
Russ - 08 May 2006 01:44 GMT
I use the code below to find out who the user is and where the
'My Documents' folder is on a Windows machine.  After creating a Project's
folder, it preps the file-save dialog with a suggested file name and folder
location in case the user wants to save the file.

Dim strDrive as String
Dim strPathDocs as String
Dim strPathTemp as String
Dim strPathMacroDocs as String
Dim objDialog as Word.Object

'Environmental variables standard to a Windows machine.
strDrive = Environ("HOMEDRIVE") 'harddrive letter the system is running on.

strPathDocs = strDrive & Environ("HOMEPATH") & "\My Documents"
'Current user's documents place.

'Current user's temp directory, if needed, to temporarily save files.
strPathTemp = Environ("TEMP")

'Create a directory for my macro project files, if they need to be saved.
If Dir(strPathDocs & "\Project Macro Documents", vbDirectory) <> "Project
Macro Documents" Then
   MkDir (strPathDocs & "\Project Macro Documents")
End If

'Make default file-save directory show as my project directory, if user
'needs to save file.
strPathMacroDocs = strPathDocs & "\Project Macro Documents"
ChangeFileOpenDirectory strPathMacroDocs

'Make default file-save name be what I suggest, if user needs to save file.
'The '1' at the end of file-save name causes the file-save name number
 'suffix to increment automatically
  'if there are similarly named files already in the suggested file-save
   'directory.
Set objDialog = Dialogs(wdDialogFileSummaryInfo)
With objDialog
   .Title = "Macro File Results Name 1"
   .Execute
End With

>> Hi
>>
[quoted text clipped - 14 lines]
>
> Paul

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID <-- fix this before replying

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.