Getting the user profile folder

J

John

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
 
J

Jay Freedman

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

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
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
J

John

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
 
H

Helmut Weber

Hi John,

probably too simple to think of it.

MsgBox Environ("Username")


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
P

Paulwh80

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

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

Paul
 
R

Russ

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
 

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