ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wildcards (https://www.excelbanter.com/excel-programming/275052-wildcards.html)

john Petty

Wildcards
 
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

Trevor Shuttleworth

Wildcards
 
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


"john Petty" wrote in message
...
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




john Petty

Wildcards
 
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
example ... though this does imply you have a default

name for the signature
file, or use the Logon ID again.

Regards

Trevor


"john Petty" wrote in message
...
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



.


Trevor Shuttleworth

Wildcards
 
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


"John Petty" wrote in message
...
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
example ... though this does imply you have a default

name for the signature
file, or use the Logon ID again.

Regards

Trevor


"john Petty" wrote in message
...
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



.





All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com