Hi guys,

Can we use the same excel object in different functions but same Action?
I guess my concern is I'm calling the subs more than 1 time and not setting 
the 
object to nothing until the end.  Is that ok?  What's the best approach?

Thanks

*Example:*

Dim objExcel, objWorkbook, objWorksheet, i

Set objExcel = CreateObject("Excel.Application")

for i = 1 to 20
      AddNumbers
      FormatNumber
Next


*Sub AddNumbers*
 objExcel.Visible = True
 Set objWorkbook = objExcel.Workbooks.open("abc.xlsx")
 set objWorksheet= objWorkbook.Worksheets("MySheet")
 objWorksheet.Activate
 Wait(2)

 objExcel.Cells(RowCount,1) = 89.98  
 objExcel.Cells(RowCount,1) = 11.3 
 objExcel.Cells(RowCount,1) = 19.00
 objExcel.ActiveWorkbook.Save
 objExcel.application.quit 
*End Sub*



*Sub FormatNumber*
 objExcel.Visible = True
 Set objWorkbook = objExcel.Workbooks.open("abc.xlsx")
 set objWorksheet= objWorkbook.Worksheets("MySheet")
 objWorksheet.Activate
 Wait(2)

 objExcel.Columns.NumberFormat = 0

 objExcel.ActiveWorkbook.Save
 objExcel.application.quit 
*End Sub*


Set objExcel = nothing
set objWorkbook = nothing
Set objWorksheet = nothing

-- 
-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to MercuryQTP@googlegroups.com
To unsubscribe from this group, send email to
mercuryqtp+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

--- 
You received this message because you are subscribed to the Google Groups "QTP 
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mercuryqtp+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to