Forum Discussion
irina_lukina
15 years agoSuper Contributor
Hi Michael,
Try using the following code snippet:
' returns TRUE if the workbook is open
function WorkbookOpen(WorkBookName)
Set Excel = Sys.OleObject("Excel.Application")
WorkbookOpen = false
count = Excel.Workbooks.Count
' Iterate through the workbooks collection
' Note that this collection is not zero-based
For i = 1 to count
if (Excel.Workbooks.Item(i).Name = WorkBookName) then
WorkbookOpen = true
end if
Next
end function
sub Main
MyWorkbookName = "myworkbook.xls"
if (WorkbookOpen(MyWorkbookName)) then
Log.Message("The workbook is open")
else
Log.Message("The workbook is not open")
end if
end sub
Does this help?