+ Reply to Thread
Results 1 to 5 of 5

VBA unable to pull value from input or form type using getelementsby method

  1. #1
    Registered User
    Join Date
    11-12-2014
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    2

    VBA unable to pull value from input or form type using getelementsby method

    I have some issues to retrieve value from a form or input type. I hope that you could help me or give me some suggestions.

    My computer info:

    1.window 8.1

    2.excel 2013

    3.ie 11

    My excel reference:

    Microsoft Object Library: yes

    Microsoft Internet Controls: yes

    Microsoft Form 2.0 Object library: yes

    Microsoft Script Control 1.0: yes

    Expected Result:

    retrieve the value "AVrO8qF_" and copy it on Cell ("c2") automatically.

    Actual Result:

    nothing return to Cell ("C2")

    url:

    http://coursesweb.net/javascript/getelementsbytagname

    Below is the HTML elements.

    <form rel="async" ajaxify="/plugins/like/connect" method="post" action="/plugins/like/connect" onsubmit="return window.Event &amp;&amp; Event.__inlineSubmit &amp;&amp; Event.__inlineSubmit(this,event)" id="u_0_1"> <input type="hidden" name="lsd" value="AVrO8qF_" autocomplete="off">



    Below is my VBA code.

    Private Sub CommandButton1_Click()
    Dim ie As Object
    Dim Doc As HTMLDocument
    Dim Elements As IHTMLElementCollection
    Dim Element As IHTMLElement

    Set ie = CreateObject("InternetExplorer.Application")

    ie.Visible = 0

    ie.navigate "http://coursesweb.net/javascript/getelementsbytagname"
    Do
    DoEvents
    Loop Until ie.readyState = 4

    Set Doc = ie.document

    Set Elements = Doc.getElementsByTagName("input")

    For Each Element In Elements
    If Element.name = "lsd" Then
    Range("c2").Value = Element.value
    End If
    Next Element

    Set Elements = Nothing

    End Sub
    Attached Images Attached Images
    Last edited by pexpex223; 11-12-2014 at 04:32 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: VBA unable to pull value from input or form type using getelementsby method

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA unable to pull value from input or form type using getelementsby method

    I am unable to see or find the ("input") on the source code.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA unable to pull value from input or form type using getelementsby method

    Hi, pexpex223,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: VBA unable to pull value from input or form type using getelementsby method

    pexpex223 has only 2 posts, why would you ban answers?

    pexpex223, there is no attachment in the attachment box and you should attach a sample workbook so somebody can have something to work with.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Input box to needs different type of variable type (RC vs. A1?)
    By Niedermee in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-18-2014, 05:00 PM
  2. Replies: 1
    Last Post: 08-28-2013, 05:04 PM
  3. Unable to use Range.End(xlDown) method
    By vedpatel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-01-2006, 12:20 AM
  4. [SOLVED] Type mismatch using rnge as Range with Type 8 Input Box
    By STEVE BELL in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-03-2005, 01:10 AM
  5. unable to type in selected row
    By Andersenjoy in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-24-2005, 11:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1