Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Deleting the excel sheet before exiting the script
#1
Solved: 10 Years, 9 Months ago
I have to delete a excel sheet before exiting the script.
Please help me out!
Thanks
-Nagesh
Reply
#2
Solved: 10 Years, 9 Months ago
Hey I found this,
Code:
Public Sub DeleteAFile(filespec)
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   On error resume next
   fso.DeleteFile(filespec)
End Sub

This is working just fine for me.
Reply
#3
Solved: 10 Years, 9 Months ago
Hi,
What about the following script.
It creates an excel file with 5 sheets.
Then removes the second sheet.
You will find the mentioned sheet deleted from the workbook.

Let me know whether it works out for you or not!

Code:
Set xls=createobject("excel.application")
Set xls1=xls.workbooks.add
For i=0 to 4
xls1.worksheets.add
next

xls.worksheets(1).name="Browsers"
'xls.worksheets(2).delete
xls1.saveas"E:\Child Object Properties2.xls"
xls.save
xls.quit
Set xls=nothing
Set xls1=nothing
Reply
#4
Solved: 10 Years, 9 Months ago
Hi..

This piece of code works fine. That is interesting.
Also i have posted another issue in the forum for changing the color of the cells in the datasheet. Please help me out with that too.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,593 01-17-2017, 11:05 AM
Last Post: JACKSPARROW
  Excel and Driver Script shipu 1 3,581 02-27-2014, 09:09 AM
Last Post: supputuri
  Custom sort -Excel Sheet kiran 1 3,690 01-28-2014, 09:23 AM
Last Post: supputuri
  Can we save an exported Excel sheet directly from QTP? Akhila 2 3,138 11-28-2013, 10:30 AM
Last Post: Akhila
  How to identify the object reference to the existing(already opened) Excel sheet yogeesh 1 9,772 09-26-2012, 07:00 PM
Last Post: krr

Forum Jump:


Users browsing this thread: 1 Guest(s)