have excel icon appear in the task bar when app is invisible

inosent

Board Regular
Joined
Mar 19, 2007
Messages
130
i have a program i use all the time, but i never directly open it with Excel. it is a set of forms that does a lot of things and it works great.

i use a .vbs file to open it:

Code:
on error resume next
set app = createobject("excel.application")
app.usercontrol = true
set wb = app.workbooks.open (replace(wscript.scriptfullname,wscript.scriptname,"file.xls"))
if wb is nothing then app.quit

i have, at the open of excel, the form launch and then make the application invisible:

Code:
Private Sub Workbook_Open()
Form1.Show
Application.Visible = False

End Sub

what this does is allows an excel related program to open w/o ever 'seeing' excel open. excel remains invisible, the 'engine' for the program, but not the program of focus.

all this is great *but* when opening excel this way no icon appears on the task bar. i was wondering if there is a way to tell excel at the open:

'open invisibly except for the icon on the task bar'

i can change the icon to my own custom icon this way:

Code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Const WM_SETICON = &H80

Sub SetExcelIcon()
Dim lngXLHwnd As Long, lngIcon As Long, strIconPath As String


'Change this to a valid icon path on your network/drive
strIconPath = "C:\myico.ICO"
lngXLHwnd = FindWindow("XLMAIN", Application.Caption)

lngIcon = ExtractIcon(0, strIconPath, 0)

SendMessage lngXLHwnd, WM_SETICON, False, lngIcon

End Sub

but if the app is otherwise invisible it wont show.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,306
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Instead of hiding the Application you can minimize it to the Taskbar.

use this to call the Form:

Code:
Application.WindowState = xlMinimized
UserForm1.Show vbModeless

where UserForm1 is the name of the Form. Change it's name as required.

Regards.
 

Forum statistics

Threads
1,141,203
Messages
5,704,931
Members
421,372
Latest member
Jamie11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top