Results 1 to 2 of 2
  1. #1
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Amersfoort, Netherlands
    Thanked 0 Times in 0 Posts

    digitaly signing a word document (Word 2003)

    Hello all,

    I would like to create a button on a word document, so the user could sign the document and the document is send by e-mail to another user.
    So I like to know what kind of information about the current user I can retreive from the system using VBA
    I know how to retreive the initials en username from the properties of Word, but the user could change them
    Is is possible to extract some user information from his windows login?
    I will store this info in the document en show his name on the document as a digital signature.

    Any sugestions are welcome.

    Patrick Schouten
    (The Netherlands)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: digitaly signing a word document (Word 2003)

    You can use Environ("username") to get the login name, but this is not entirely dependable either since the user can change environment variables. The following code uses a Windows API function:

    Private Declare Function GetUserName Lib "advapi32.dll" _
    Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Public Function WindowsUser() As String
    Dim strUsername As String
    strUsername = String(100, vbNullChar)
    GetUserName strUsername, 100
    WindowsUser = Left$(strUsername, InStr(strUsername, vbNullChar) - 1)
    End Function

    The declaration of GetUsername must be at the top of a module. The function can be somewhere below it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts