SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to select button of Excel pop up dialog

    Hi,

    I have the excel dialog which I need to click "OK", "Cancel" to close the dialog.

    How can I operate excel dialog and close it.

    Thanks

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Location
    Michigan, USA
    Posts
    840
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to select button of Excel pop up dialog

    In what scripting lang? VBA?
    A problem is a difference between what is perceived and what is desired, that
    we want to reduce
    (Dewey 1933)

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to select button of Excel pop up dialog

    Sorry, forgot about it.

    On VBS script

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Location
    Michigan, USA
    Posts
    840
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to select button of Excel pop up dialog

    Sorry, can't help with VBS script... In fact I haven't heard of it.
    A problem is a difference between what is perceived and what is desired, that
    we want to reduce
    (Dewey 1933)

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to select button of Excel pop up dialog

    Hi Drazle,

    Thank you for your thread,
    Here is the script to pop up the dialog:

    <font class="small">Code:</font><hr /><pre>Set ObjApp = CreateObject("Excel.Application")
    ObjApp.Visible = False
    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    Set ObjWBs = ObjApp.Workbooks
    Set ObjWorkBook = objApp.workbooks.Add()
    objWorkBook.SaveAs("c:\WorkBook.xls")
    ObjWorkBook.SaveAs("c:\WorkBook.xls")</pre><hr />

    Actually, I don't know the method to handle this kind of dialog.

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Location
    Michigan, USA
    Posts
    840
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to select button of Excel pop up dialog

    For 1 thing, you are trying to save the file twice which can cause the popup. Also if you already ran this script, then c:\WorkBook.xls will already exist.

    I don't think you can handle that popup within the code per se. You should look up the help for SaveAs (workbook version) which has an optional prameter not to display the "conflict resolution dialog" that you are trying to close.

    So you need to check if that file already exists in your code or delete it before you run - and only try to save it once. See MSDN website for File System Object help too.

    Also, since you are not cleaning up the objects, this script leaves and Excel process running each time which can be seen in Windows Task Manager, you need to close the Excel object to avoid this memory leak (leaving this open can also lock the object so that it can't be deleted either). Another good practice is to set the objects to Nothing, though that doesn't matter in this case since the script ends, which does the same thing.

    Here is a version of your script that checks for the file, deletes it if there, then save's the new workbook.
    <font class="small">Code:</font><hr /><pre>Set objApp = CreateObject("Excel.Application")
    Set objWorkBook = objApp.Workbooks.Add()
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    strFile = "c:\WorkBook.xls"

    If objFSO.FileExists(strFile) Then
    objFSO.DeleteFile (strFile)
    End If

    objWorkBook.SaveAs (strFile)

    objWorkBook.Close
    Set objFSO = Nothing
    Set objWorkBook = Nothing
    Set objApp = Nothing
    </pre><hr />
    A problem is a difference between what is perceived and what is desired, that
    we want to reduce
    (Dewey 1933)

  7. #7
    Member
    Join Date
    Sep 2008
    Location
    India
    Posts
    422
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to select button of Excel pop up dialog

    We can also use this

    objExcelApp.DisplayAlerts = False

    can supply the command on default focus.
    ~Vivek
    -------------------------------------------
    Software Testing Interview Question and Answer
    --------------------------------------------

 

 

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 10.71%
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:15 AM.

Copyright BetaSoft Inc.