Hello:
I am opening an Excel spreadsheet using a WB script, but I want to wait until the user closes the spreadsheet before continuing in the program. Any ideas?
Also, Is there a way to open the spreadsheet fullscreen?
Thanks in advance
RunWait()?
WinExist()?
AppExist()?
AppWaitClose()?
WinWaitClose()?
Are a few options.
Jim
I don't get it. Even AFTER I close the spreadsheet, the task manager indicates that Excel is still running. My program never comes back after a
AppWaitClose, WinWaitClose, or any of the others. Here's my Code:
;------------------------------------- Code Starts Here ---------------------------------
; Call sub-routine to check to see if Excel is installed on this machine...
gosub CheckExcelInstalled
; If Excel is NOT installed, terminate the program...
If ! IsInReg("Excel.Application")
display(2,"Cannot Run Script","Requires Microsoft Excel To Be Installed")
Exit
Endif
;Define .XLS file and sheetname to activate...
ExcelFileName = "C:\Customers.xlsx"
WorkSheetName = "by Wages"
; Open the Spreadsheet (Window is: 0 = Invisible 1 = Visible)...
Visible=1
gosub OpenExcelSpreadsheet
;When user closes spreadsheet, return to Startup.exe...
AppWaitClose("~Excel")
Run("Startup.exe","")
Exit
;========================== SUBROUTINES GO HERE ===========================
; *******************************************************************
; UDF Registry Check for MS Excel... Is Excel Installed on this PC?...
; *******************************************************************
:CheckExcelInstalled
#DefineFunction isInReg(cProg)
Return( RegExistKey(@RegClasses,cProg) )
#EndFunction
Return
; *******************************************************************
; Subroutine to open an Excel Spreadsheet...
; *******************************************************************
:OpenExcelSpreadsheet
; Open Excel
EXA = ObjectOpen("Excel.Application")
; If Visible=0 (Open invisible) Visible=1 (Open visible)...
If Visible==0 Then EXA.Visible = 0
Else EXA.Visible = 1
EXA.DisplayAlerts = 0
MyWorkbook = EXA.workbooks
MWO = MyWorkbook.open(ExcelFileName)
; Get active workbook object
AWB = EXA.activeworkbook
; Get WorkSheetName (First worksheet in spreadsheet)
WorkSheetName = AWB.Worksheets(1).name
; get worksheet object
AWS = AWB.worksheets(WorkSheetName)
;Activate worksheet
AWS.Activate
Return
I got it figured out!
Such a simple solution.
Thanks for your help... It really got me thinking SIMPLE
RunWait("Excel.exe","Customerss.xlsx")
Run("Startup.exe","")
Exit
Quote from: oradba4u on February 28, 2015, 10:17:28 PM
I don't get it. Even AFTER I close the spreadsheet, the task manager indicates that Excel is still running. My program never comes back
It seems like you figured it out, but I have always relied upon GetObject() to determine if an instance of Excel is still running.