Wildcards

J

john Petty

Is there a way that I can modify a macro from an
individuals location (i.e. C:\Documents and
Settings\turdavl\Desktop\Davidsig.JPG") to a wildcard
search?

(Note: I am trying to create a macro in a template to
enable users to place their individual signatures into a
cell (insert object).

Thanks in advance.

John Petty
 
T

Trevor Shuttleworth

John

well, you can get the User's Logon ID using the following routines:

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

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

You could then build the folder name as:

"C:\Documents and Settings\" & fOSUserName & "\Desktop\DefaultSig.JPG" for
example ... though this does imply you have a default name for the signature
file, or use the Logon ID again.

Regards

Trevor
 
J

John Petty

Thank you Trevor. You da Man.
-----Original Message-----
John

well, you can get the User's Logon ID using the following routines:

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

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

You could then build the folder name as:

"C:\Documents and Settings\" & fOSUserName
& "\Desktop\DefaultSig.JPG" for
 
T

Trevor Shuttleworth

John

you're welcome. I have to admit that the code MUST have come from the group
at some point in time so the credit, sadly, is not all mine. Still, it
makes me feel good to be help others as I have been helped.

Regards

Trevor
 

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