SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Jun 2004
    Posts
    289
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Help with my SaveAs method

    On my SaveAs line, I get a Run Error of :

    SaveAs method of Workbook class failed

    Function file: O:\QTP Tests\NightlyRegressionTesting\Tests\LibraryImageA ccessFunctions.qfl
    Line (1250): " objExcel.ActiveWorkbook.SaveAs(FilePath)

    My code:

    Public Function SaveOrSaveAsExcelSheet (FilePath, objExcel)

    Set objFso = CreateObject("Scripting.FileSystemObject")

    bFileExist = objFso.FileExists(FilePath)

    objExcel.Visible = True
    objExcel.DisplayAlerts = False

    If Not bFileExist Then
    objExcel.ActiveWorkbook.SaveAs(FilePath) 'ERROR ON THIS LINE
    Else
    objExcel.ActiveWorkbook.Save
    End If

    objExcel.DisplayAlerts = True
    objExcel.ActiveWorkbook.Close
    objExcel.Quit
    Set objExcel=Nothing
    Set objFso=Nothing

    End Function

    Any ideas on why?

    thx
    Thx for the help ;-)

    see ya

    Lorena

  2. #2
    Advanced Member
    Join Date
    Sep 2011
    Posts
    524
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Help with my SaveAs method

    Can you put breakpoint on 4th line of the function (displayalerts one) and then let us know if the excel workbook at filepath is opened.

    If not, then you need to open excel workbook at filepath and then this code should work fine.

  3. #3
    Member
    Join Date
    Jun 2004
    Posts
    289
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Help with my SaveAs method

    Yes, it is open.

    thx for looking

    L
    Thx for the help ;-)

    see ya

    Lorena

  4. #4
    Advanced Member
    Join Date
    Sep 2011
    Posts
    524
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Help with my SaveAs method

    I think it is not opened because in the above code, there is no objExcel.Workbooks.open () statement

    Also, can you replace bFileExist with objFso.FileExists(FilePath) in following line of code:

    If Not bFileExist Then

    and let me know if it works

    and execute the following line of code just before If statement:

    msgbox objFso.FileExists(FilePath)

    please let me know, what shows in the msgbox?

 

 

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 11.54%
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 12:09 AM.

Copyright BetaSoft Inc.