Re: How can I insert the default Outlook signature into a document

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks, that's pretty much what the other code that I mentioned did.
Instead of assuming that the signatures will be on drive C: (they're
not), I'm using the APPDATA environment variable. This makes it point
to the appropriate place (U:\Settings\Application Data in my case)
without having to look up the user name :)

Chris


zkid wrote:
Chris,

The signatures are located in the following folder:

C:\Documents and Settings\[UserName]\Application Data\Microsoft\Signatures

Each signature has three versions from which to choose: .rtf, .txt or
.html (txt wipes out any formatting).

Use the following code to determine the user's login name to maneuver to the
correct folder:

Option Explicit

'Declare for call to mpr.dll.
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long

Const NoError = 0 'The Function call was successful

Function GetCurUser() As String

'Buffer size for the return string.
Const lpnLength As Long = 255

'Get return buffer space.
Dim status As Integer

'For getting user information.
Dim lpName, lpUserName As String

'Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)

'Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)

'See whether error occurred.
If status = NoError Then
'This line removes the null character. Strings in C are null-
'terminated. Strings in Visual Basic are not null-terminated.
'The null character must be removed from the C strings to be used
'cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
End If

'Display the name of the person logged on to the machine.
GetCurUser = lpUserName

End Function


"Chris Mahoney" wrote:

I've found a solution, for WordMail at least. There's a post here from
last year, the abominably-named "Word VBA Question" that tells me
exactly what to do :)

I have yet to try non-WordMail signatures though.



.



Relevant Pages