Forum Discussion

fbonds_1's avatar
12 years ago

VBscript: Dealing with "Save Changes" window

I'm making my windows app open a bunch of files in succession from a folder.  Due to the nature of the app, it occassionally makes necessary alterations to a file on load such that when the script attempts to open the next file a "Save Changes?" window pops up.  I'm trying to nuke this by testing if the window is there every iteration and sending No if so.



The window appears as dlgXYZ when I record myself manually moving the focus with the right arrow from "Yes" to "No" and sending enter:




  Call dlgXYZ.btnYes.Keys("![ReleaseLast][Right]")


  Call dlgXYZ.btnNo.Keys("[Enter]")


 


In the editor, I see that dlgXYZ has a ".Exists" property(?).



How do I write the IF/THEN to use that to execute the above?



I tried:




If dlgXYZ.Exists then 


  Call dlgXYZ.btnYes.Keys("![ReleaseLast][Right]")


  Call dlgXYZ.btnNo.Keys("[Enter]")


End If




but it doesn't like that.  Errors on the the IF with "Object required: 'dlgXYZ'"



How do I test to see if the dialog is there properly with my IF/THEN?



Thanks!!
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Fletcher,


     


    As you are using Name Mapping in your test, the code will be like this:




    Set wnd = ' dlgXYZ's parent


    If wnd.WaitAliasChild("dlgXYZ", 3000).Exists then 


     Call dlgXYZ.btnYes.Keys("![ReleaseLast][Right]")


     Call dlgXYZ.btnNo.Keys("[Enter]")


    End If