I am using a .vbs script to open a .xlsm file to avoid the Excel Splash Screen (this is the little square that pops up showing that Excel is loading). The .vbs script also hides the Toolbar Ribbon and puts the Excel 2016 into full screen but introduces the annoying Title Bar that contained a mini Excel icon and a " - Excel " suffix after the file Name. Found code for this which worked on my 32-bit Excel. I need to use this on my work laptop but it has 64-bit Excel. I added PtrSafe in my declaration, but the icon changing part of the code doesn't seem to do anything.
The below code is the original code to change the icon. Since I tried using the code on the 64-bit Excel on my company laptop, I had to add PtrSafe between Declare and Function in the Module 1 Code. EDIT: So upon further research I discovered that when calling Windows API using long datatypes, long need to be updated. So they should be changed from Long to LongPtr or LongLong. I tried both and it now tells me there's a Type mismatch on ExtractIcon32 in Sub ChangeApplicationIcon(). I had changed every instance of Long (8). EDIT2: BigBen pointed out that Icon& means Icon As Long. So I implemented his edit of changing Icon& to "Icon As LongPtr". The code runs without error but still doesn't change the icon. EDIT3: I have tried the fixes on a 64-bit version of excel on my personal gaming desktop but the icon still doesn't change. So it's probably not because of any possible restrictions on my company laptop.
'******CODE FOR THISWORKBOOK MODULE****
Option Explicit
Private Sub Workbook_Open()
Application.Caption = " - Company Name "
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 > [removed link to avoid rule-breaking]
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
'*****************************************
Upon Executing this code, the full-screen Excel's titlebar icon should be changed from Excel 2016 Icon to the Notepad Icon.