Excel application flashing before hiding when using Application.Visible propety

Shameem Khan

New Member
Joined
Aug 9, 2020
Messages
13
Office Version
  1. 2013
Platform
  1. Windows
I am trying to open a Userform without opening excel application. After some searching, I found the codes to do that. It is working fine, however the Excel window always opens before it hides. Is there anyway to avoid flashing of the excel window so that only the userform shows up and nothing else. I have set the following code inside ThisWorkbook object in Excel VBA.

Private Sub Workbook_open()
Application.Visible = False
Application.ScreenUpdating = False
Uf_Randomizer.Show vbModeless
End Sub

Please help, Thanks in advance.

P.S- I am new to this
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
TTBOMK, you will need to create a launcher such as a script file or exe. Before going that far, create a shortcut to your document and select Minimized for the Run option. Maybe that will do...

1596985581326.png
 
Upvote 0
Thanks @dataluver . Not actually what I was looking for, but Good Idea. And what did you mean by creating a launcher. Did you mean to create a batch file(.bat) file to open the excel file or is there any way to convert the excel file into exe file ? Just curious....
 
Upvote 0
Hi Shameem. In this example, the script file will be in the same folder as the workbook. When you fire up an instance of Excel as an automation server, the default is an invisible application instance. So it will never show unless you explicitly show it. As a side, there may be a command line argument that will work for you. That may be an option worth checking into.

There is an example of the following in this folder which contains a folder named Launch Invisible Instance which, in turn, contains the three files mentioned below. Download the folder as is.

Create a macro enabled workbook with UserForm1 containing this code:
VBA Code:
Private Sub UserForm_Terminate()
    Application.Quit
End Sub

Place this code in your workbook class:
VBA Code:
Private Sub Workbook_Open()
    UserForm1.Show
End Sub

Create a script file. Launcher.vbs, for example:
VBA Code:
Dim fso, FolderName, xl
Set fso = CreateObject("Scripting.FileSystemObject")
FolderName = fso.GetParentFolderName(Wscript.ScriptFullName)
set xl = CreateObject("Excel.Application")
xl.Workbooks.Open FolderName & "\Example Launcher.xlsm"

If you wish, you can then create a shortcut to your script file, changing the icon of the shortcut to suit.
 
Upvote 0
Solution
I want to hide excel workbook when running the vba project for client side.So, I'm Application.Quit in QueryClose() function.Now ,show userform only but can't go back to excel workbook. How can I go back to excel workbook to edit something code.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,165
Members
448,870
Latest member
max_pedreira

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
Back
Top