Micro Focus QTP (UFT) Forums
Deleting the excel sheet before exiting the script - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Deleting the excel sheet before exiting the script (/Thread-Deleting-the-excel-sheet-before-exiting-the-script)



Deleting the excel sheet before exiting the script - nageshpv - 08-04-2008

I have to delete a excel sheet before exiting the script.
Please help me out!
Thanks
-Nagesh


RE: Deleting the excel sheet before exiting the script - nageshpv - 08-04-2008

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.


RE: Deleting the excel sheet before exiting the script - Rekha - 08-14-2008

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



RE: Deleting the excel sheet before exiting the script - nageshpv - 08-18-2008

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.