How to open Excel workbook (QTP, VBScript)
Parent page: Service Functions – Excel (QTP, VBScript)
Description
Check the file exists – Create an instance of Excel by using COM – open (load) file
Dim XLHandle, XLBook
Public Function OpenWorkbook(ByVal sFileName)
Dim FSO, boolRC
Set FSO = CreateObject("Scripting.FileSystemObject")
boolRC = FSO.FileExists(sFileName)
Set FSO = Nothing
If Not boolRC Then
OpenWorkbook = FALSE
Exit Function
End If
Set XLHandle = CreateObject("Excel.Application")
XLHandle.DisplayAlerts = False
Set XLBook = XLHandle.WorkBooks.Open(sFileName)
OpenWorkbook = TRUE
End Function

