Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple excel automation
#1
Solved: 10 Years, 9 Months, 3 Weeks ago
I wrote following code for a task
task: There are two column A and B, these are parameterized with some values in data table. Using this values with calculator I want to calculate WOR and type output in excel's row(1,1) for first iteration and next value in cell(2,1) for second iteration. Please help

Code:
Set oexcel = createobject("Excel.Application")  'to create excel
oexcel.Visible = true
oexcel.Workbooks.Add

If not  Window("Calculator").Exist(1) Then
systemutil.Run ("C:\WINDOWS\system32\calc.exe")
End If
Window("Calculator").WinEdit("Edit").Type DataTable("A", dtGlobalSheet)
Window("Calculator").WinButton("/").Click
Window("Calculator").WinEdit("Edit").Type DataTable("B", dtGlobalSheet)
Window("Calculator").WinButton("=").Click
WOR = window("Calculator").WinEdit("Edit").GetROProperty("text")
Window("Calculator").WinButton("C").Click
oexcel.Workbooks.cells(1,1).value = WOR
Reply
#2
Solved: 10 Years, 9 Months, 3 Weeks ago
Check this -

Code:
iRow = DataTable.GetCurrentRow 'Get the current row count from DataTable
Set oexcel = createobject("Excel.Application")  'to create excel
oexcel.Visible = true
oexcel.Workbooks.Add
Set objSheet1 = oexcel.Sheets("Sheet1")

If not  Window("Calculator").Exist(1) Then
systemutil.Run ("C:\WINDOWS\system32\calc.exe")
End If
Window("Calculator").WinEdit("Edit").Type DataTable("A", dtGlobalSheet)
Window("Calculator").WinButton("*").Click
Window("Calculator").WinEdit("Edit").Type DataTable("B", dtGlobalSheet)
Window("Calculator").WinButton("=").Click
WOR = window("Calculator").WinEdit("Edit").GetROProperty("text")
Window("Calculator").WinButton("C").Click
objSheet1.Cells(iRow,1).Value = WOR
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  where can I find the help for excel & database automation abhi_biradar2006 0 1,870 05-20-2014, 01:08 AM
Last Post: abhi_biradar2006
  Need Excel template for mapping manual scripts to Automation scripts. ACCBAJPA 0 2,840 09-19-2013, 03:02 PM
Last Post: ACCBAJPA
  Add Simple Text Header mot0rola 2 2,353 07-09-2013, 10:30 AM
Last Post: Ankur
  Excel automation Sathiya 1 3,478 11-17-2012, 06:48 PM
Last Post: Ankesh
  Problem recording simple script shik_and 4 4,613 04-16-2012, 05:49 PM
Last Post: saikri

Forum Jump:


Users browsing this thread: 1 Guest(s)