Get ID for button in iframe and click it via VBA

I am trying to programmatically click a button of a popup iframe. Here is the code for the iframe:
<iframe width="100%" id="iMaintenancePopup" src="../oa/Common/maintenancePopup.aspx" frameborder="0" scrolling="no" style="height: 723px;"></iframe>

Open in new window

Here is the screenshot for the popup iframe:OfficeAllyPopup.pngHow do I get the ID for the button that states: "I acknowledge this message" and how do I click it using VBA?
LVL 39
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Firstly, right-click on the button and select "Inspect Element" (the exact term may be different depending on the browser you're using).
Next, find the button id.
Finally, use some code like this:
Public Sub EE_Demo()

    Dim objIE As Object
    Dim objElement As Object

    ' Create InternetExplorer Object
    Set objIE = CreateObject("InternetExplorer.Application")

    ' Make sure the Internet Explorer window is visible
    objIE.Visible = True
    ' Navigate to your URL
    objIE.Navigate "your link"

    ' Wait while IE loading...
    Do While objIE.Busy
        Application.Wait DateAdd("s", 3, Now)

    ' Get the button
    Set objElement = objIE.document.getElementsById("buttonid")
    ' Click the button

    ' Clean up
    Set objIE = Nothing
    Set objElement = Nothing

End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thenelsonAuthor Commented:
In IE, I right-clicked on the button and selected "Inspect Element" but the button did not display in the DOM Explorer (or any of the other tabs).
Try in Chrome or Firefox.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

thenelsonAuthor Commented:
Ok, so I found that the button ID is "btnAcknowledge".

does not work, The automation does not see the button because it is in an iframe.
also does not work.

I am looking for the correct syntax for referencing the button in an iframe.
thenelsonAuthor Commented:
Or some other way to close the popup iframe if it pops up.
thenelsonAuthor Commented:
I found the correct code to click the button:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.