Zip code research

Asked

Viewed 131 times

2

I am developing a solution and the need to add the CEP research has arisen. Return would like to get the address based on the CEP informed.

I started writing the code below but stopped at it.

Sub lsPesquisaCEP(ByVal sCEP As String)
    On Error GoTo TratarErro

    Range("Consulta!a1:H1").Clear

    If sCEP <> "" Then
        With ActiveWorkbook.XmlMaps("webservicecep_Mapa")
            .ShowImportExportValidationErrors = False
            .AdjustColumnWidth = True
            .PreserveColumnFilter = False
            .PreserveNumberFormatting = False
            .AppendOnImport = False
        End With
        ActiveWorkbook.XmlImport URL:= _
            "http:/republicavirtual.com.br/web_cep.php?cep=" & sCEP, ImportMap:= _
            Nothing, Overwrite:=False, Destination:=Range("Consulta!$a$1")


    End If

    Calculate

Sair:
    Exit Sub
TratarErro:
    MsgBox "CEP não cadastrado!"
    GoTo Sair
    Resume
End Sub

Always gives as unregistered zip code!

  • 1

    You can search the site of the post office, the problem is that they block for access in excess. Because they sell this service, called DNE. Then you must pay either way or for the post office or some application that provides this service. Or if you find any updated ZIP Code website for free, you can make queries in the database of this website. Or if you have a CEP database, you can locate with VBA

  • 2

    Could you review my question before you put it out of scope????

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.