Forum Discussion

guna's avatar
New Contributor
2 years ago

object required error

Hi all,

 I am upgrading from 14 to 15 version recently. I am unable to get it this one, some times the code is executing successfully and sometimes getting Object required error, below one is the code


Dim TestReportFolder ,Test_reportexcel ,FinalTest_reportexcel

Function GetRecentExcel_InsertData

Set fso = CreateObject("Scripting.FileSystemObject")
Set recentExcel = Nothing
For Each file in fso.GetFolder(Test_Report_Path).Files
If (recentExcel is Nothing) Then
Set recentExcel = file
ElseIf (file.DateLastModified > recentExcel.DateLastModified) Then
Set recentExcel = file
End If

If recentExcel is Nothing Then
log.Message( "No recent Test Report")

Test_reportexcel = recentExcel.Name

End If

aqUtils.Delay 1000
aqUtils.Delay 2000
Set app = Sys.OleObject("Excel.Application")
TestReportFolder = Test_Report_Path
FinalTest_reportexcel = TestReportFolder + "\" + Test_reportexcel
Set TestReportWorkBook =app.Workbooks.Open(FinalTest_reportexcel) --->at this line i am getting object required error

1 Reply

  • rraghvani's avatar
    Champion Level 3

    My VBScript is not very good, but I'm able to write the following code to launch and open the Excel file


    Sub Test1()
        Dim Excel, Filename
        Filename = "C:\Temp\Book1.xlsm"
        Set Excel = Sys.OleObject("Excel.Application")
        Excel.Visible = True
    End Sub


    Ensure you have Excel installed, and that the user has correct permissions. Also, ensure that the filename follows the Universal Naming Convention, i.e. "C:\Temp\Book1.xlsm" is different to this "C:\\Temp\\Book1.xlsm"