Question

I will try to make this as clear as possible, and any help is appreciated. So thanks in advance.
I am wanting to create an inspection form template that will automatically pull the windows login information, then go to a server location and pull in a (same as login)named picture file with an .jpg or .png of the users actual penned signature to sign several tabs in the same excel file.

Windows User id's are unique as this is a business. The server location will not change paths. The server file location will need to be locked to read only so it can not be tampered with, which should not interfere with reading a file to insert it(mentioning it just in case).

I want the user to open the blank form I create. Their windows login information will automatically fill in the signature box. And when they have completed the inspection, they can print to pdf and save in the proper filled in form location. I do not want nor need the information to stay static across other computers in the excel file. if the local user saves a copy they wish to update, it will only see their signature.

I would prefer the unique username to update the the users actual name, which could be kept in a locked excel file on the server as well, but that might be asking too much and I can have them type it in if needed.

All of the signatures on the file would be the same.

EDIT - recorded macro

Sub Sig_server2() 
' Sig_server2 Macro 
' Keyboard Shortcut: Ctrl+s 

    Environ ("username") ' supposed to define the variable based
                         ' on the windows login information 

    Sheets("Inspectiontype").Select ' Selects the tab to add the signature on 
    Range("H19:R19").Select 'Selects the range where picture is to be inserted 

    ' need "jamesmor" to change to the "username" variable
    ActiveSheet.Pictures.Insert("Y:\QA\Signatures\jamesmor.png").Select 

    Range("S19:V19").Select ' Drops to the next blank to be filled
                            ' in which is the inspection stamp number
End Sub
Was it helpful?

Solution

This should do it...

Sub Tester()
    Const SERVER_PATH As String = "Y:\QA\Signatures\"
    Dim usr As String, fPath As String

    usr = Environ("username")
    fPath = SERVER_PATH & usr & ".png"

    If Dir(fPath, vbNormal) = "" Then
        MsgBox "Signature file for '" & usr & "' not found!"
        Exit Sub
    End If

    InsertPicFile fPath, Sheets("Inspectiontype").Range("H19")
    '...do other inserts

End Sub

Sub InsertPicFile(sigPath As String, rng As Range)
    With rng.Parent.Pictures.Insert(sigPath)
        .Left = rng.Cells(1).Left
        .Top = rng.Cells(1).Top
    End With
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top