Excel

Change Excel Icon

Ease of Use

Intermediate

Version tested with

2000 

Submitted by:

johnske

Description:

On opening the workbook, the application icon is changed to one of your own choice. 

Discussion:

You may wish - perhaps (say) because they're created from a different template - to personalize some Excel workbooks so they're immediately distinguishable from other workbooks. 

Code:

instructions for use

			

'******CODE FOR THISWORKBOOK MODULE****** Option Explicit Private Sub Workbook_Open() Application.Caption = " My Personalized Workbook" ChangeApplicationIcon End Sub '***************************************** '************CODE FOR MODULE1************* Option Explicit Declare Function GetActiveWindow32 Lib "USER32" Alias _ "GetActiveWindow" () As Integer 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 Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias _ "ExtractIconA" (ByVal hInst As Long, _ ByVal lpszExeFileName As String, _ ByVal nIconIndex As Long) As Long 'modification of code from Excel Experts E-Letter Archives. 'Original code By Jim Rech can be found by following this 'link > http://www.j-walk.com/ss/excel/eee/eee020.txt Sub ChangeApplicationIcon() Dim Icon& '*****Change Icon To Suit******* Const NewIcon$ = "Notepad.exe" '***************************** Icon = ExtractIcon32(0, NewIcon, 0) SendMessage32 GetActiveWindow32(), &H80, 1, Icon '< 1 = big Icon SendMessage32 GetActiveWindow32(), &H80, 0, Icon '< 0 = small Icon End Sub '*****************************************

How to use:

  1. Open an Excel workbook
  2. Select Tools/Macro/Visual Basic Editor
  3. In the VBE window, select View/Project Explorer
  4. Select the 'ThisWorkbook' Module, copy and paste the code for it from above
  5. Select Insert/Module, copy and paste the code for module1 into this module.
  6. Now select File/Close and Return To Microsoft Excel
  7. Save your work and close the workbook.
 

Test the code:

  1. On opening the workbook, the Excel 'X' icon should be changed to the Notepad icon.
  2. Note that there are plenty of other icons to choose from. To find the icons you can use, go to Start/Find/Files Or Folders... and type in exe in the 'Named:' window then click Find Now... Any of these icons can be used e.g. FONTVIEW.EXE, or MPLAYER.EXE, ... etc.
 

Sample File:

ChangeApp.Icon.zip 11.79KB 

Approved by mdmackillop


This entry has been viewed 352 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express