VBA and Dom

CallMeAndy

Registered User.
Local time
Today, 08:18
Joined
Jun 21, 2005
Messages
14
Using VBA from Access to automate IE .

I have this not assigning a value to the innerHTML as expected.

Code:
Function PasteToWebPage(txt As String, ie As SHDocVw.InternetExplorer, Optional IfNotExactlyOne As htmlNotExactlyOne = htmlPasteToNone, Optional ElementID As String, Optional ClassName As String, Optional Name As String, Optional TagName As String, Optional href As String, Optional InnerHTML As String) As Long
Dim hDoc As MSHTML.HTMLDocument
Dim hCol As MSHTML.IHTMLElementCollection
Dim hSelect As MSHTML.HTMLSelectElement
'Dim Target As IHTMLInputElement
On Error GoTo errorHandler

Set hDoc = ie.Document

With hDoc
    
    If ElementID <> "" Then
        'ignores any value set for htmlNotExactlyOne
        .getElementByID(ElementID).InnerHTML = txt
        'If Target Is Nothing Then Err.Raise vbObjectError + 513
        'Target.setAttribute "value", txt

        PasteToWebPage = 1
        Exit Function
    End If
...

I can assign to value i.e. .getElementByID(ElementID).value = txt works fine but doesn't change the visual content on the form - confused which I should use and why its not working.

Err.Number=600 Err.Description=Application-defined or object-defined error

Any help appreciated thanks!
 
Think I have got to the bottom of it or at least found the right pond.

This was the test input tag.
<input type="search" role="search" placeholder="Search MDN" id="q" name="q" value="">

type="search" is html5 , the browser is ie8, I guess we have a compatibility issue but that said I cant see an example of a value being assigned anywhere to an input tag of type="search"

Any web guru's have a comment please.
 

Users who are viewing this thread

Back
Top Bottom