Results 1 to 2 of 2
  1. #1
    gabriel_vba is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2020
    Posts
    1

    Internet Explorer and Access VBA - My VBA code works in excel and I want to translate for access

    Greetings to all, I use the code below to track goods on the website of the Brazilian post office using MS Excel, I would like to know how do I convert this code to Microsoft Access, what objects, methods and libraries should I use. Any questions I am at your disposal.
    The code create a connection with internet Explorer

    [COLOR=rgba(0, 0, 0, 0.87)]Sub rastreios()
    On Error Resume Next
    [/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Sheets("ProdutosImportados").Select[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Dim linha As Integer[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Dim ie As Object[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]linha = 1[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Cells(linha, 1).Select[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Do Until Cells(linha, 10).Value = "Objeto entregue ao destinatário "[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Set ie = CreateObject("internetexplorer.application")[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]ie.navigate "https://www2.correios.com.br/sistemas/rastreamento/default.cfm"[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]ie.Visible = True[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]On Error Resume Next[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Do While ie.Busy And ie.readyState <> "READYSTATE_COMPLETE"[/COLOR]


    [COLOR=rgba(0, 0, 0, 0.87)]DoEvents[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Loop[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]ie.document.getElementsByClassName("f8col fldSRO f3row")(0).Value = Cells(linha, 8).Value[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]ie.document.getElementsByClassName("btn1 float-right btnSubmit")(0).Click[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Do While ie.Busy And ie.readyState <> "READYSTATE_COMPLETE"[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]DoEvents[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Loop[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Cells(linha, 9) = ie.document.getElementsByClassName("sroDtEvent")(0 ).innerText[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Cells(linha, 10) = ie.document.getElementsByClassName("sroLbEvent")(0 ).innerText[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]ie.Quit[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Cells(linha, 12) = Now[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]linha = linha + 1[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)][/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]Loop[/COLOR]
    [COLOR=rgba(0, 0, 0, 0.87)]End Sub[/COLOR]

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    I suggest you try to paste the code again using the code tags (#) in this forum. Anyway most code should work, you will need to replace the Excel specific elements with a reference to an Access table in which you would insert the records in your current loop.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-16-2018, 10:47 AM
  2. Trying to control Internet Explorer in VBA
    By Glenn_Suggs in forum Modules
    Replies: 21
    Last Post: 09-25-2014, 08:44 AM
  3. VBA > Internet Explorer
    By Stokecpa in forum Programming
    Replies: 3
    Last Post: 08-06-2012, 01:10 AM
  4. Internet Explorer automation with VBA
    By sa230e in forum Programming
    Replies: 0
    Last Post: 09-29-2011, 05:04 PM
  5. Replies: 0
    Last Post: 09-03-2009, 01:58 PM

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
  •  
Other Forums: Microsoft Office Forums