Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Web Query. Log on Username & Password

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Query. Log on Username & Password

    Hello to all , as you can see in the code below, I need :
    1) navigate to a web page
    2) submit my userId and password
    3) beeing redirected to a different url I have to menage this situation for passing url to
    4) quering sub
    I am using Excel 2000 with win98
    Error 429 Can't create object:which one?please help
    Code:
    Public Sub First()
    Dim obEx As Object
    Dim obj As New MSHTML.HTMLBody
    Dim strPass As String
    Dim elUid As New MSHTML.HTMLInputElement
    Dim elPass As New MSHTML.HTMLInputElement
    Dim elSubmit As New MSHTML.HTMLInputElement
    Dim strUid As String
    Dim Desc As String
    
    strUid = "something"        'UserID
    strPass = "something"         'my password
    
        On Error GoTo HandleError
      Set obEx = CreateObject("InternetExplorer.Application")
      
      With obEx
      .navigate "http://registrazioni.directaworld.it/quotazioni/index.php3" 'Main URL
      
      Do While .Busy: DoEvents: Loop
                Do While .readyState <> 4: DoEvents: Loop
    
      Set obj = obEx.document.body
      'Now submit UserId,Password and click submit
      Set elUid = obj.getElementsByTagName("INPUT").Item("u")
      elUid.Value = strUid
      Set elPass = obj.getElementsByTagName("INPUT").Item("p")
      elPass.Value = strPass
      Set elSubmit = obj.getElementsByTagName("INPUT").Item("Submit")
      elSubmit.Click
      'Loop until IE is redirect to URL to query which I Know partially
     Do While Not CBool(InStrB(1, .LocationURL, _
            "start.php?t=00007275"))
            DoEvents
     Loop
      
        Do While .Busy: DoEvents: Loop
        Do While .readyState <> 4: DoEvents: Loop
       
     End With
     Desc = obEx.LocationURL    'URL to Query
     Call Connetti(Desc)
     
    obEx.Quit
    Set obEx = Nothing
    Set obj = Nothing
    
    HandleExit:
        
        Exit Sub
    
    HandleError:
    obEx.Quit
    Set obEx = Nothing
    Set obj = Nothing
        ErrorHandle Err, Erl(), "Module1.First"
        Resume HandleExit
    End Sub
    Thanks

  • #2
    Re: Connecting the web for querying

    Please don't use tags in thread titles.
    .

    Comment


    • #3
      Re: Connecting the web for querying

      I saw it only when I posted,I apologize it,sorry, it is the first post for me,regards,Giogugio

      Comment


      • #4
        Re: Connecting the web for querying

        OK, no problem.
        .

        Comment


        • #5
          Re: Connecting the web for querying

          See Create Internet Explorer Object

          Comment


          • #6
            Re: CreateObject. Can't Create Object

            Thanks Dave;I was not able to retrieve that help in MS site
            When I debugged the sub on my computer it seemed to me that it was fine

            Comment


            • #7
              Re: CreateObject. Can't Create Object

              Please stop using Bold on all your posts.

              Don't know what you mean by "not able to retrieve". Link is fine.

              Comment


              • #8
                Re: CreateObject. Can't Create Object

                Now It works , if someone is interested : I will post.
                Regards

                Comment


                • #9
                  Re: CreateObject. Can't Create Object

                  Yes please, always share any solutions in keeping with the spirit of the forum.

                  Comment


                  • #10
                    Re: CreateObject. Can't Create Object

                    I hope it will be usefull . I am learning so I have some scruple to post code.
                    Code:
                     Public Sub WebAccess()
                    Dim strUid As String    'UserID
                    Dim strPass As String    'Password
                    Dim strQueryURL As String    'URL to query
                    Dim objIE As New SHDocVw.InternetExplorer
                    Dim htmlDoc As MSHTML.HTMLDocument
                    Dim htmlInput As MSHTML.HTMLInputElement
                    Dim htmlColl As MSHTML.IHTMLElementCollection
                    Dim testing As String
                    
                    
                        strUid = "YourId"
                        strPass = "YourPass"
                        
                        Set objIE = CreateObject("InternetExplorer.Application")
                        
                        With objIE
                        .navigate "Your URL" 'Main URL
                        Do While .Busy: DoEvents: Loop
                                Do While .readyState <> 4: DoEvents: Loop
                        
                        Set htmlDoc = .document
                        Set htmlColl = htmlDoc.getElementsByTagName("INPUT")
                        
                    
                        For Each htmlInput In htmlColl
                                    If htmlInput.Name = "Itsname" Then htmlInput.Value = strUid
                                    If htmlInput.Name = "Itsname" Then htmlInput.Value = strPass
                        Next htmlInput
                        For Each htmlInput In htmlColl
                                    If htmlInput.Name = "Itsname" Then
                                htmlInput.Click
                            Exit For
                            End If
                            Next htmlInput
                    Do While .Busy: DoEvents: Loop
                        Do While .readyState <> 4: DoEvents: Loop
                        
                        End With
                        strQueryURL = objIE.LocationURL
                        Call ConnettionSUB(strQueryURL)
                        
                      
                        Set htmlDoc = Nothing
                        objIE.Quit
                        Set objIE = Nothing
                    End sub
                    Regards

                    Comment


                    • #11
                      Re: CreateObject. Can't Create Object

                      Thanks giogugio. I'm sure someone will find it of great use.

                      Comment


                      • #12
                        Re: Web Query. Log on Username &amp; Password

                        Hi Giogugio,

                        i tried out your code but am getting stuck. the line
                        Code:
                         Dim objIE As New SHDocVw.InternetExplorer
                        gets highlighted and and a compile error - User defined type not defined - is generated. I think i need to do something with the object browser. can you tell me how?

                        thanks
                        Geetha

                        Comment

                        Trending

                        Collapse

                        There are no results that meet this criteria.

                        Working...
                        X