Hello all! New to Ozgrid and still relatively new to VBA, so please forgive me in advance if I sound ignorant.
I have created a few userforms in both Excel and Word. They are working properly and I was able to figure out how to get the userform to show in the taskbar. What I can't figure out is how to set a custom icon to the taskbar item.
My goal is to change this: [ATTACH=CONFIG]69141[/ATTACH]
Into this: [ATTACH=CONFIG]69142[/ATTACH]
I have tried the following, with no success:
Code
Private Declare Function GetActiveWindow32 Lib "USER32" Alias _
"GetActiveWindow" () As Integer
Private Declare Function SendMessage32 Lib "USER32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias _
"ExtractIconA" (ByVal hInst As Long, _
ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long
Private Sub ChangeIcon()
ChangeApplicationIcon
End Sub
Sub ChangeIcon()
Dim Icon&
Const NewIcon$ = "Image2"
Icon = ExtractIcon32(0, NewIcon, 0)
SendMessage32 GetActiveWindow32(), &H80, 1, Icon
SendMessage32 GetActiveWindow32(), &H80, 0, Icon
End Sub
Display More
"Image2" is the .ico image that is on the userform and set as not visible. Any assistance would be greatly appreciated!