0

I deal with this code. Here I want to click on a button but then a box appears that I am not able to deal with.

 <input type="image" name="senden" src="/img/misc/b_go.gif" alt="Go" 
  title="Go" value="submit" 
  onclick="return confirm('Willst du wirklich jetzt deine Aufstellung und Taktik festlegen?');">

First, button click:

Set ButtonAufstellung = objIE.document.getElementsByName("senden")(0)
    ButtonAufstellung.Click

Second, the popup appears and I get asked if I am really sure. I can click Ok or Cancel but I always want to click Ok. I could not find any solution that works.

I tried some solutions, but was not able to implement them.

Here somebody had a simillar problem but I did not understand: How to click a JavaScript confirm popup via excel vba

Edit:

Solutions that do not work:

Element.onclick = "Submit()"
Element.onclick = "True"
Element.onclick = "OK"
Element.onclick = "SendKeys{ENTER}"
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
  • maybe instead of clicking the button...call the underlying javascript that the button calls (after the confirmation)...example on how to call javascript form vba - http://www.vbaexpress.com/forum/showthread.php?9690-Solved-call-a-javascript-function – Ctznkane525 Jan 21 '18 at 23:23
  • It did not work.I tried different approaches. Pressing Enter did not work either. I think there must be some elegant way to do it. Application.OnKey "{RETURN}", "Sub_Enter" Application.OnKey "{ENTER}", "Sub_Enter" – Grigorij Abramov Jan 21 '18 at 23:45
  • whats the javascript look like that has the button?...the buttons whole tag – Ctznkane525 Jan 21 '18 at 23:51
  • I would prefer a solution that does not change any java, because i need to save and this does not work then. it must be a solution that, where vba is able to see the popup and click the button. – Grigorij Abramov Jan 22 '18 at 00:15
  • Vba is single threaded...I think your thread will be waiting on the dialog...not 100 percent sure but...that might be a challenge to the approach you want to achieve – Ctznkane525 Jan 22 '18 at 00:54
  • Could you please share the webpage URL, and also what is the final goal? Do you need to retrieve some data from the page? If so, have you tried XHR instead of IE? – omegastripes Jan 22 '18 at 05:15
  • Easiest fix is to overwrite the `window.confirm` function with one which just returns `true`: https://stackoverflow.com/questions/30228144/how-to-call-javascript-function-in-vba/30229398#30229398 – Tim Williams Jan 22 '18 at 06:15

0 Answers0