UFT won’t update Excel worksheet
Question ID: 108069
1
0

I’m trying to update cells in an Excel Worksheet using UFT 14.01. The script runs without error, but when it finishes, the cells are not updated. My code is below. Any ideas why it’s not working?

Set objExcelApp = createobject("excel.application")

Set objFSO = CreateObject("Scripting.FileSystemObject")
blnReturn = objFSO.FileExists(ExcelFileLocation)
If blnReturn Then
objExcelApp.Workbooks.Open ExcelFileLocation
WorkbookName=objExcelApp.ActiveWorkbook.Name
objExcelApp.Application.Visible = true
objExcelApp.sheets("Invoices").activate

Set OrderInvoices = objExcelApp.Sheets("Invoices")
Set SheetName = objExcelApp.Sheets("SheetName")

OrderInvoices.cells(1,1) = "Customer Number"
OrderInvoices.cells(1,2) = "Invoice Number"
OrderInvoices.cells(1,3) = "Order Issue Date"
OrderInvoices.cells(1,4) = "Order Delivery Date"

objExcelApp.ActiveWorkbook.Save
objExcelApp.ActiveWorkbook.Close
objExcelApp.Application.Quit

Set OrderInvoices =nothing
Set objExcelApp = nothing
Set SheetName=nothing

Marked as spam
Posted by (Questions: 386, Answers: 64)
Asked on January 17, 2018 4:44 pm
47 views
Answers (1)
1
Private answer

Add .value to your update statements:

OrderInvoices.cells(1,1).value = ''Customer Number''
OrderInvoices.cells(1,2).value = ''Invoice Number''
OrderInvoices.cells(1,3).value = ''Order Issue Date''
OrderInvoices.cells(1,4).value = ''Order Delivery Date''

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on January 17, 2018 4:44 pm
0
That worked, thanks!
( at January 17, 2018 4:45 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top