Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2016, 11:22 AM
derajlance derajlance is offline Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Novice
Change Userform Icon in Taskbar
 
Join Date: May 2016
Posts: 18
derajlance is on a distinguished road
Default Change Userform Icon in Taskbar

I think I finally got all of my forms completed and working properly. Now I am trying to just do some cosmetic things.

Specifically, at this point, I am wanting to change the icon that shows in the taskbar for the userform.
I want to change this:

Into this:

I've tried the following code, but have not had any 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
"Image2" is the .ico image that is on the userform and set as not visible.
Reply With Quote
  #2  
Old 05-17-2016, 08:17 PM
gmayor's Avatar
gmayor gmayor is offline Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You would do better to create a ribbon tab/button for your procedures. See http://gregmaxey.com/word_tip_pages/...bbon_main.html
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 05-18-2016, 08:11 AM
derajlance derajlance is offline Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Novice
Change Userform Icon in Taskbar
 
Join Date: May 2016
Posts: 18
derajlance is on a distinguished road
Default

Thanks again for always responding so quickly!

I may be missing something, so I just want to clarify. After looking over that information, I only see the option to change the Ribbon information. I am actually wanting to change the Icon that shows up in the taskbar at the bottom of the screen. Did I miss a section about that?
Reply With Quote
  #4  
Old 05-18-2016, 05:36 PM
Guessed's Avatar
Guessed Guessed is online now Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Is there a good reason why you are not using a valid filepath to the ico file as per the posts where it appears you sourced your code?
see http://stackoverflow.com/questions/2...-while-loading

When I tested that code, it changed the icon in the app header and the icon associated with the app when Alt-tabbing through the available apps but didn't appear to change the icon in the already loaded taskbar. Perhaps that code needs to be run as the application is booting.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 05-19-2016, 02:43 PM
derajlance derajlance is offline Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Novice
Change Userform Icon in Taskbar
 
Join Date: May 2016
Posts: 18
derajlance is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Is there a good reason why you are not using a valid filepath to the ico file as per the posts where it appears you sourced your code?
see http://stackoverflow.com/questions/2...-while-loading

When I tested that code, it changed the icon in the app header and the icon associated with the app when Alt-tabbing through the available apps but didn't appear to change the icon in the already loaded taskbar. Perhaps that code needs to be run as the application is booting.
The post that I sourced my code from actually uses a .exe file to pull an icon. Specifically, it uses notepad.exe.
I was attempting to get an image that is not associated with a different application. Trying to piece together information from various sources, it was recommended that I include the .ico image I want to use on the userform and use it in the code, which is what I attempted to do in my code above.

I do realize that I was doing that wrong as well and have attempted to correct it by using:
Code:
Const NewIcon$ = Me.Image1.Picture.Handle
and get the same result. Which is the same as what you described. It doesn't seem to matter much where I put the code, so I am not really sure it can be done.
Reply With Quote
  #6  
Old 05-19-2016, 06:59 PM
Guessed's Avatar
Guessed Guessed is online now Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It appears from the screen shot in the URL I posted that it can be done but there may be a couple of reasons why it doesn't work for us.
It might work in earlier versions of Windows but not in the version I have running (Windows 10)
It might not work if the application is pinned to the start menu (according to some other threads found with Google)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 05-20-2016, 02:40 PM
derajlance derajlance is offline Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Novice
Change Userform Icon in Taskbar
 
Join Date: May 2016
Posts: 18
derajlance is on a distinguished road
Default

FYI - I was able to figure it out after almost a week of trying..

It appears that the coding must be included in both the ThisDocument object and the Userform coding.
Attached Images
File Type: jpg userform.jpg (16.1 KB, 29 views)
Reply With Quote
  #8  
Old 06-01-2019, 08:02 PM
thilag80 thilag80 is offline Change Userform Icon in Taskbar Windows 10 Change Userform Icon in Taskbar Office 2013
Novice
 
Join Date: Jun 2019
Posts: 1
thilag80 is on a distinguished road
Default

Hi

You mentioned to add the code in 'ThisDocument' object. Could you please clearly explain what is 'thisdocument' object and what is the code needs to be there? Where I have to enter the code you initially provided. Sorry I'm newbie
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
OneNote Icon on Taskbar Query kevitec57 OneNote 0 03-22-2016 06:37 AM
Taskbar icon always moves when saving Adobe PDF from Word WaltR Word 0 10-03-2015 09:41 AM
Change parent for control from frame to userForm? Cosmo Word VBA 0 05-30-2014 02:19 PM
ICONS change to a different icon lrmaps.423 Windows 0 04-11-2014 07:53 AM
Change Contacts View icon folder to List arthurshurn Outlook 0 10-29-2013 09:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:24 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft