Interacting with a Gif

whatasks22

New Member
Joined
Jan 11, 2019
Messages
5
Hey guys my third post i am sorry. I am new at VBA and trying to interact with what i am think is a GIF i need to click to expand the table. attached is the html and my current code.
HTML:
<div class="A976bc0611e7a4e20b05d61c1efb873f5818" id="Pcda281654e7f49028c2c6bb20cd0566c_1_601" role="navigation" style="width: 34.78mm; display: flex; min-height: 10.57mm; min-width: 34.78mm; justify-content: center; align-items: flex-start; -webkit-align-items: flex-start; -webkit-justify-content: center;" aria-label="Report text"><a tabindex="4" id="Pcda281654e7f49028c2c6bb20cd0566c_1_601_na" aria-expanded="false" aria-labelledby="Pcda281654e7f49028c2c6bb20cd0566c_1_601_aria" style="padding-right: 2px; padding-left: 2px; cursor: pointer;" onkeypress="if(event.keyCode == 13 || event.which == 13){var rp=$get('ReportViewerControl_ctl09_ReportControl');if(rp&&rp.control)rp.control.InvokeReportAction('Toggle','601',event);return false;}" *******="var rp=$get('ReportViewerControl_ctl09_ReportControl');if(rp&&rp.control)rp.control.InvokeReportAction('Toggle','601',event);return false;"><img onerror="this.errored=true;" alt="Expand View Installed Applications" src="/ReportServer/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=14.0.600.490&Name=Microsoft.ReportingServices.Rendering.HtmlRenderer.RendererResources.TogglePlus.gif" border="0"></a><div style="width: 30.12mm; min-width: 30.12mm;">View Installed Applications</div></div>
<a tabindex="4" id="Pcda281654e7f49028c2c6bb20cd0566c_1_601_na" aria-expanded="false" aria-labelledby="Pcda281654e7f49028c2c6bb20cd0566c_1_601_aria" style="padding-right: 2px; padding-left: 2px; cursor: pointer;" onkeypress="if(event.keyCode == 13 || event.which == 13){var rp=$get('ReportViewerControl_ctl09_ReportControl');if(rp&&rp.control)rp.control.InvokeReportAction('Toggle','601',event);return false;}" *******="var rp=$get('ReportViewerControl_ctl09_ReportControl');if(rp&&rp.control)rp.control.InvokeReportAction('Toggle','601',event);return false;"><img onerror="this.errored=true;" alt="Expand View Installed Applications" src="/ReportServer/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=14.0.600.490&Name=Microsoft.ReportingServices.Rendering.HtmlRenderer.RendererResources.TogglePlus.gif" border="0"></a>
<img onerror="this.errored=true;" alt="Expand View Installed Applications" src="/ReportServer/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=14.0.600.490&Name=Microsoft.ReportingServices.Rendering.HtmlRenderer.RendererResources.TogglePlus.gif" border="0">

and my current vba
Code:
Sub Assetgrabber()
Dim myValue As Variant
myValue = InputBox("Asset Tag")
Range("A2").Value = myValue






Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://spv-msccm-rs02/ReportServer/Pages/ReportViewer.aspx?%2fCustom%2f_Generic%2fDeviceFullReport&rs:Command=Render&CompName=" & Range("A2").Value
ie.Visible = True
 
        Set tdCollection = ieDoc.getElementById("P31bb5549bb3a43b6883baf411089c331_1_601_na").getElementsByTagName("td")
        For Each Cell In tdCollection
            If Cell.ID = toFind Then
                Cell.FireEvent ("***********")
                Cell.FireEvent ("onmousedown")
                Cell.FireEvent ("onmouseup")
                Exit Sub
            End If
        Next


End Sub
 
Last edited by a moderator:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
It's very difficult to help without access to the page, so I can only provide general tips.

The img tag is inside an anchor (a) tag, which should be clickable. Also, I expect the id="P31...." changes every time, so specifying the full id won't work - look instead for the id containing "601_na". On that basis, try the following code (put it after the IE.Visible):
Code:
    Dim HTMLdoc As HTMLDocument
    Dim link As HTMLAnchorElement
    Dim i As Long
    While IE.Busy Or IE.readyState <> 4: DoEvents: Wend
    Set HTMLdoc = IE.document
    Set link = Nothing
    i = 0
    While i < HTMLdoc.Links.Length And link Is Nothing
        If InStr(HTMLdoc.Links(i).id, "601_na") Then Set link = HTMLdoc.Links(i)
        i = i + 1
    Wend
    If Not link Is Nothing Then
        link.Click
    Else
        MsgBox "Link not found"
    End If
The above code requires a reference to Microsoft HTML Object Library, which allows you to define variables with the appropriate HTML data type. Set the library via Tools->References in the VBA editor.
 
Last edited:
Upvote 0
It's very difficult to help without access to the page, so I can only provide general tips.

The img tag is inside an anchor (a) tag, which should be clickable. Also, I expect the id="P31...." changes every time, so specifying the full id won't work - look instead for the id containing "601_na". On that basis, try the following code (put it after the IE.Visible):
Code:
    Dim HTMLdoc As HTMLDocument
    Dim link As HTMLAnchorElement
    Dim i As Long
    While IE.Busy Or IE.readyState <> 4: DoEvents: Wend
    Set HTMLdoc = IE.document
    Set link = Nothing
    i = 0
    While i < HTMLdoc.Links.Length And link Is Nothing
        If InStr(HTMLdoc.Links(i).id, "601_na") Then Set link = HTMLdoc.Links(i)
        i = i + 1
    Wend
    If Not link Is Nothing Then
        link.Click
    Else
        MsgBox "Link not found"
    End If
The above code requires a reference to Microsoft HTML Object Library, which allows you to define variables with the appropriate HTML data type. Set the library via Tools->References in the VBA editor.

Thanks but I am getting a runtime error 462 on line
While IE.busy or IE.Readystate <>4
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top