Does anyone know the code to minimize Excel in the background while an XL form is open.
For this to work right you want to have a process run 'on-open' to display your user form, and you want to open a new instance of the Excel Application when your program starts. Then when the form is closed the Excel application is closed with the userform. This will prevent multiple copies of Excel being opened.
Create a Shortcut for your application. The target path must point to the Excel App. you must type exactly this format
with the quotes included in the paths.
Target:
"C:\Program Files\Microsoft Office\Office\EXCEL.EXE" "C:\Program Files\BackUtility\Backup.xls"
Start In:
"C:\Program Files\Microsoft Office\Office"
Run:
'Minimized' (list option)
This code will minimize the Excel App. But if you don't use Run Minimized in a shortcut the user will see the window go to the task bar. Once Minimized you must call 'AppActivate' and SetFocus to the form or your user form will not be accessable without the user physically clicking the Application title in the taskbar. Change the app title and file paths to match your system of course.
Code:
' Modless is called from the workbook_open sub
' auto runs when workbook is opened
' set it in ThisWorkbook Excel Object
Sub Modeless()
' Developed 1/20/04 savBill
Application.Caption = "Backup Program"
Application.ShowWindowsInTaskbar = False
Application.WindowState = xlMinimized
ReturnExcel
Application.Assistant.Visible = False
UserForm1.cmdBackupFiles.SetFocus
UserForm1.Show
End Sub
Sub ReturnExcel()
AppActivate "Backup Program"
End Sub
Secondary Note:
Check out
http://archive.baarns.com/. The Excel developer Jump start package uses a process to hide all the toolbars, but makes a list to put them all back on close. Fair warning, it was written for Excel 97. I did not have good luck with the toolbar hiding process when I tried it once a long time ago. Theres some good stuff in there, may give you some ideas.
/