SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 10 of 10
  1. #1
    Member
    Join Date
    Apr 2005
    Location
    Pune
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Save an open excel sheet

    I have a web link clicking on which opens the results in an excel sheet. I have to save this opened excel sheet in a network shared drive. Please let me know how I can save an already open excel sheet.

  2. #2
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Set Obj = GetObject(, "Excel.Application")
    Obj.Save "\\.....\test.xls"
    Set Obj = Nothing

  3. #3
    Member
    Join Date
    Apr 2005
    Location
    Pune
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Thanks Reddy, the above code is working but partially.
    It creates a "C:\test.xls" but it seems that the test.xls file is just a reference to the xls already open. The size of test.xls is 1KB.
    Also, when I am trying to save the above code in my test in QTP, I am getting a syntax error at following line -
    Set Obj = GetObject(, "Excel.Application")

    ~ Kapil.

  4. #4
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet


    >I am getting a syntax error at following line -
    Set Obj = GetObject(, "Excel.Application")<

    Not possible... Syntax here is absolutely correct.
    Something wrong in another place...
    Try this line only on new TestCase - it might be that you've made a lot of changes in your current TC, working hard and totally confused QTP :]

    Also try this:
    http://www.qaforums.com/ultimatebb.p...;f=20;t=004653
    where you'll find the codes of chillyhouse52556 and Tarun for embedded Excel.

    Janna

  5. #5
    Member
    Join Date
    Apr 2005
    Location
    Pune
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Janna/Reddy,

    I am afraid I am still getting at syntax error at line -
    Set Obj = GetObject(, "Excel.Application")
    This time I created a new test and then tried to save the file.
    Please find the screenshot attached.
    Attached Images Attached Images

  6. #6
    Member
    Join Date
    Oct 2003
    Location
    Norfolk, VA
    Posts
    360
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Include a space prior to the comma.
    GetObject( ,"Excel.Application")
    A good rule of thumb is to never measure with your thumb.

  7. #7
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Just run the following and see what happens?

    SystemUtil.CloseProcessByName "Excel.exe"
    Set xl = CreateObject("Excel.Application")
    SystemUtil.Run "Excel.exe"
    Wait(10)
    Set xl = GetObject(,"Excel.Application")
    If xl Is Nothing Then
    ExitRun
    End If
    xl.visible = True
    xl.Worksheets(1).Activate
    xl.Cells(1,1).Value = "Cell11"
    xl.Cells(1,2).Value = "Cell12"
    xl.activeworkbook.SaveAs("C:\test.xls")
    xl.Application.Quit

  8. #8
    Member
    Join Date
    Apr 2005
    Location
    Pune
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    I get an "Unknown Runtime Error" at line -
    xl.Worksheets(1).Activate
    I think the above code will not help because at first line itself it will close the open excel which I want to save.
    Also, here again I am getting that syntax error at the same line - Set xl = GetObject(,"Excel.Application")
    I tried giving spaces, double quotes etc before the comma (,). Nothing works [img]/images/graemlins/frown.gif[/img]

  9. #9
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Looks like some issue with QTP installation or something else on your machine, It works fine for me.

  10. #10
    Member
    Join Date
    Nov 2002
    Location
    TX, USA
    Posts
    96
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Save an open excel sheet

    Did you try this -

    str1 = "Set xl = GetObject(,""Excel.Application"")"
    Execute str1
    '// xl will now have the object reference. So the below ex. work -
    Set a1 = xl.Worksheets(1)
    a1.Cells(1, 1).Value = "sss"
    !BRA!NZ!/
    ~~~~~~
    ☺ ▓☺▓

    ..Mouth of a Dagger and Heart of Tofu

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.09%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:08 PM.

Copyright BetaSoft Inc.