English 中文(简体)
传统观念的归属
原标题:Getting attribute values in VBA

我需要制作一个将读成网页的VBA文件,并回去IMG tag的SRC属性的价值。 我无法完成最后一步的工作。 你们能够帮助我吗?

<html>
<body>
<img src="image.jpg">
</body>
</html>

===Edit=== I managed to return the attribute object. Now I need to return its value

Option Compare Database

Sub AcessaPagina()
    Dim ie As InternetExplorer
    Dim test As String
    Dim obj As Object

    Set ie = New InternetExplorer
    ie.Navigate "http://www.google.com.br"
    MsgBox ie.Document.getElementsByTagName("img").Item(0).Attributes("src")
    ie.Visible = True 
End Sub

这符合我目前的情况。

最佳回答

没有任何称为“植被”的方法,即:getElementsByTagName。 页: 1 因为它是一种收集。

页: 1

Sub AcessaPagina()
    Dim ie As Object   InternetExplorer
    Dim images As Object   MSHTML.IHTMLElementCollection
    Dim image As Object   MSHTML.IHTMLElement

    Set ie = CreateObject("InternetExplorer.Application")
    ie.navigate "http://www.google.com.br"
    Set images = GetAllImages(ie)

    For Each image In images
      Debug.Print image.getAttribute("src")
    Next image

End Sub

Function GetAllImages(ie As Object) As Object
  Set GetAllImages = ie.document.images
End Function
问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签