I've been looking tutorials and examples of setting the value field of a input tag. I'm trying to enter two IP addresses into the text fields on this website, under IP Range To CIDR. But my code won't enter anything.

There's no ID tag, so I can't use the getElementById method.


Dim url As String

Sub ConvertIPRangeToCIDR()

    Dim IE As InternetExplorer
    Set IE = New InternetExplorerMedium

     With IE
        .Visible = True
        url = "https://www.ipaddressguide.com/cidr"
        .navigate (url)

        While IE.Busy

        Dim Elements As Object
        Set Elements = IE.Document.getElementsByTagName("input")
        For Each Element In Elements
            If Element.Name = "ipFrom" Then
                Element.Value = ""
            Exit For
            End If
        Next Element
        End With
End Sub

From tutorials this looks easy, but I've been trying different things and nothing is working.

I got it to work by changing lines 5 & 6 to:

    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

Not sure how the previous method was not working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.