ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Minimize Excel When Running a Macro (https://www.excelbanter.com/excel-programming/298537-minimize-excel-when-running-macro.html)

Paul Vovk

Minimize Excel When Running a Macro
 
Seems like this is a simple thing, but I can't seem to get
it. I want Excel to run minimized when the macro (VBA
code) runs. A separate script starts Excel and this macro.
The macro runs and then shuts down Excel. This is done
once per day. I need the macro to first minimize Excel so
it doesn't show up on the screen while the macro is
running as it takes ~10 minutes to run.

tod

Minimize Excel When Running a Macro
 
You can have your script open Excel in memory and not have
it appear on the screen, like this:

'Create an instance of Excel
Set xl = CreateObject("Excel.Application")
'Open the workbook
Set CurrentBook = _
xl.Workbooks.Open"C:\MyPath\MyWorkbookName.xls")
'Run a procedure called Main in Module1
xl.Run "Main"
'Save and Close the workbook
CurrentBook.Save
CurrentBook.Close
'Close the instance of Excel
xl.Quit

Excel, nor the workbook, will never appear on the screen.

tod

set CurrentBook = nothing
set xl = nothing


-----Original Message-----
Seems like this is a simple thing, but I can't seem to

get
it. I want Excel to run minimized when the macro (VBA
code) runs. A separate script starts Excel and this

macro.
The macro runs and then shuts down Excel. This is done
once per day. I need the macro to first minimize Excel so
it doesn't show up on the screen while the macro is
running as it takes ~10 minutes to run.
.



All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com