Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    24

    Unanswered: VBA and DOM to populate an input tag

    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!

  2. #2
    Join Date
    Jan 2005
    Posts
    24
    Think I have got to the bottom of it or at least found the right pond.

    Firstly innerHTML was the wrong attribute as it seems there isnt one for an input tag. However I had laos tried using innertext and value also to no avail.

    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"

    I wonder if this is possible.

    Any web guru's have a comment please.
    Andy Seabrook
    One of the virtually challenged: find me at virtualenergy.co.uk
    or say hello on Facebook
    or get adventurous at Adventurebods

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •