Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error while saving an already opened Excel
#1
Not Solved
Hi Team,

I am trying to save an Excel generated by an application to my local drive. When the excel is generated, I do not know the worksheet name, so I tried the following code :

Code:
Set objExcel = Eval("GetObject(,""Excel.application"")")    
objExcel.DisplayAlerts = False
Set xlBook=objExcel.Workbooks
Set xlBook = objExcel.ActiveSheet
xlBook.Activate
xlBook.SaveAs("c:\test.xls")

But QTP throws an error stating : Object required at line number 4 (xlBook.Activate).

I am not able to understand the issue here, as the Excel is open and I can see it.

Any help is appreciated.

Thankx.
Reply
#2
Not Solved
Try this:

Code:
Set objExcel = Eval("GetObject(,""Excel.application"")")    
objExcel.DisplayAlerts = False
Set xlBook=objExcel.Workbooks.ActiveWorkbook
Set xlSheet = xlBook.ActiveSheet
xlSheet.Activate
xlBook.SaveAs("c:\test.xls")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [UFT] Close opened folder robertosalemi 1 3,389 02-10-2016, 07:06 PM
Last Post: robertosalemi
  On Saving Script in QTP 11 my Global Data Sheet data is removed M Adnan Iftikhar 0 2,195 06-02-2015, 09:19 PM
Last Post: M Adnan Iftikhar
  QTP 11, Win 7 - Issue while saving the Excel through the script.bu fine in XP sivasuman 0 2,355 11-15-2013, 01:38 PM
Last Post: sivasuman
  Can QTP AOM identify word documents that are already opened anil2u 2 4,433 09-05-2013, 12:45 PM
Last Post: anil2u
  Getting ODBC error while executing the sql query in excel(DB) Shkumari 5 5,025 05-10-2013, 06:15 PM
Last Post: Shkumari

Forum Jump:


Users browsing this thread: 1 Guest(s)