Support please can link this as this is not an workbook open event but an APi Im trying to get to work with your software. You may close the other open event as its an API issue thanks
Does Workbook open event work in compiled workbook? XLS Padlock
Sub ChangeExelIcon()
'Get the icon handle.
'You can use the full path of the icon file, i.e.:
hwndIcon = ExtractIconA(0, “C:\Users\Christos\Desktop\MyApp\Icon.ico”, 0)
'Or the icon path relative to the current workbook, i.e.:
'hwndIcon = ExtractIconA(0, ThisWorkbook.Path & “$SIGN.ico”, 0)
'Check if the icon handle is valid.
If hwndIcon <> 0 Then
End If
We tried the following without any luck
Option Explicit
Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal ClassName As String, ByVal WindowName As String) As Long
Declare Function ExtractIcon Lib “shell32.dll” Alias “ExtractIconA” (ByVal Instance As Long, ByVal ExeFileName As String, ByVal IconIndex As Long) As Long
Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hWnd As Long, ByVal Message As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Const WM_SETICON = &H80
Public Function PathToFile(filename As String)
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & filename
Exit Function
Err:
PathToFile = “C:\Program Files\Test\Test.exe & $SIGN.ico”
End Function
Public Sub SetExcelIcon(ByVal IconPath As String)
Dim A As Long
Dim hWnd As Long
Dim hIcon As Long
hWnd = FindWindow(“XLMAIN”, Application.Caption)
hIcon = ExtractIcon(0, IconPath, 0)
If hIcon > 1 Then
Call SendMessage(hWnd, WM_SETICON, True, hIcon)
Call SendMessage(hWnd, WM_SETICON, False, hIcon)
End If
End Sub
Public Sub ChangeExcelIcon()
Dim file_name As String
file_name = “$SIGN.ico”
Call SetExcelIcon(“C:\Program Files\Test$SIGN.ico”)
I went back to my original macro and only tried pathtofile instead of Thisworkbook.Path but Im getting an error argument not optional
This is now 6 days and I cannot make this api work which work in all versions of excel
here is the code I tried that argument not optional error
Sub ChangeExcelIcon()
Dim XLSPadlock As Object
Dim hIcon As Long
hwndIcon = ExtractIconA(0, PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & “$SIGN.ico” ,0)
The line that work in Excel
hwndIcon = ExtractIconA(0, ThisWorkbook.Path & “$SIGN.ico”, 0) -This is the line that work in Excel
Here I am inserting the PathToFile This line after PathToFile
hwndIcon = ExtractIconA(0, PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & “$SIGN.ico” , 0)
Argument not optional
What am I missing please? .Hope someone can help.
This is the Excel macro -it works flawlessly in Excel but not in your softwareOk here is my code Support. My Icon is “Icon.ico”-Thank you Sub ChangeExelIcon() 'Get the icon handle. 'You can use the full path of the icon file, i.e.: hwndIcon = ExtractIconA(0, "C:\Users\Christos\Desktop\MyApp\Icon.ico", 0) 'Or the icon path relative to the current workbook, i.e.: 'hwndIcon = ExtractIconA(0, ThisWorkbook.Path & "\$SIGN.ico", 0) 'Check if the icon handle is valid. If hwndIcon <> 0 Then 'Change the icon. 'For a big icon (32 x 32 pixels), use this line: 'SendMe…
Sub ChangeExelIcon()
'Get the icon handle.
'You can use the full path of the icon file, i.e.:
hwndIcon = ExtractIconA(0, “C:\Users\Christos\Desktop\MyApp\Icon.ico”, 0)
'Or the icon path relative to the current workbook, i.e.:
'hwndIcon = ExtractIconA(0, ThisWorkbook.Path & “$SIGN.ico”, 0)
'Check if the icon handle is valid.
If hwndIcon <> 0 Then
Code:
'Change the icon.
'For a big icon (32 x 32 pixels), use this line:
'SendMessageA Application.HWnd, WM_SETICON, ICON_BIG, hwndIcon
'For a small one (16 x 16 pixels), use the next line (typical case):
SendMessageA Application.hWnd, WM_SETICON, ICON_SMALL, hwndIcon
'Inform the user.
'MsgBox "Excel icon was changed successfully!", vbInformation, "Done"
We tried the following without any luck
Option Explicit
Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal ClassName As String, ByVal WindowName As String) As Long
Declare Function ExtractIcon Lib “shell32.dll” Alias “ExtractIconA” (ByVal Instance As Long, ByVal ExeFileName As String, ByVal IconIndex As Long) As Long
Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hWnd As Long, ByVal Message As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Const WM_SETICON = &H80
Public Function PathToFile(filename As String)
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & filename
Exit Function
Err:
PathToFile = “C:\Program Files\Test\Test.exe & $SIGN.ico”
End Function
Public Sub SetExcelIcon(ByVal IconPath As String)
Dim A As Long
Dim hWnd As Long
Dim hIcon As Long
hWnd = FindWindow(“XLMAIN”, Application.Caption)
hIcon = ExtractIcon(0, IconPath, 0)
If hIcon > 1 Then
Call SendMessage(hWnd, WM_SETICON, True, hIcon)
Call SendMessage(hWnd, WM_SETICON, False, hIcon)
End If
End Sub
Public Sub ChangeExcelIcon()
Dim file_name As String
file_name = “$SIGN.ico”
Call SetExcelIcon(“C:\Program Files\Test$SIGN.ico”)
I went back to my original macro and only tried pathtofile instead of Thisworkbook.Path but Im getting an error argument not optional
This is now 6 days and I cannot make this api work which work in all versions of excel
here is the code I tried that argument not optional error
Sub ChangeExcelIcon()
Code:
'The call below works fine when you explictly define the path to the file
'Call SetExcelIcon(“C:\Users\Christos\Desktop\MyApp\Icon.ico”)
'If you want to use excel’s “ThisWorkbook.path” you would need to
'call XLS function as described below.
'this line would have to be changed to call XLS Function PathToFIle
'hwndIcon = ExtractIconA(0, ThisWorkbook.Path & “$SIGN.ico”, 0) -This is the line that work in Excel
Dim hIcon As Long
hwndIcon = ExtractIconA(0, PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & “$SIGN.ico” ,0)
Code:
Dim file_name As String
file_name = "$SIGN.ico"
SetExcelIcon ("C:\Program Files\Test\$SIGN.ico")
End Sub
hwndIcon = ExtractIconA(0, ThisWorkbook.Path & “$SIGN.ico”, 0) -This is the line that work in Excel
Here I am inserting the PathToFile This line after PathToFile
hwndIcon = ExtractIconA(0, PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & “$SIGN.ico” , 0)
Argument not optional
What am I missing please? .Hope someone can help.
Last edited:


