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

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



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

  • Re: How can I insert the default Outlook signature into a document
    ... Instead of assuming that the signatures will be on drive C: ... ByVal lpUserName As String, ... 'Buffer size for the return string. ...
    (microsoft.public.word.vba.general)
  • Re: How can I insert the default Outlook signature into a document
    ... Instead of assuming that the signatures will be on drive C: ... I'm using the APPDATA environment variable. ... ByVal lpUserName As String, ...
    (microsoft.public.word.vba.general)
  • Re: VB6 and Windows Media Player
    ... within the My Music Folder. ... Private Declare Function ShellExecute Lib "shell32.dll" Alias ... "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal ... the folder Documents and Settings eg:- C:\Documents and Settings? ...
    (microsoft.public.vb.general.discussion)
  • Re: File Input Question
    ... To have a user select a folder, not a file, I use the below. ... pszDisplayName As String 'Address of a buffer to receive the display name of the folder ... Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long ... Private Declare Function GetWindowRect Lib "user32" ...
    (microsoft.public.excel.programming)
  • Re: Execute macro for all documents in the folder
    ... It is simple enough to batch process a single folder. ... Dim strFileName As String ... It seems as though the below macro from an earlier posting was put ...
    (microsoft.public.word.docmanagement)