Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por Handred
Posts
#17474
Bom dia Pessoal, estou utilizando uma macro para puxar o endereço com base no CEP.

então ao digitar o CEP no textbox
Código: Selecionar todos
Private Sub cep_Exit(ByVal Cancel As MSForms.ReturnBoolean)

lsPesquisaCEP (cep.Value)

logradouro.Value = UCase(Sheets("TEMP").Range("G1"))
bairro.Value = UCase(Sheets("TEMP").Range("E1"))
cidade.Value = UCase(Sheets("TEMP").Range("D1"))
uf.Value = UCase(Sheets("TEMP").Range("C1"))

End Sub
onde vai para a macro no módulo1
Código: Selecionar todos
Sub lsPesquisaCEP(ByVal sCEP As String)
    On Error GoTo TratarErro
    
    Range("TEMP!$A$1:$H$1").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("TEMP!$A$1")
            
            
            
    End If
        
    Calculate
    
Sair:
    Exit Sub
TratarErro:
    MsgBox "CEP não cadastrado!"
    GoTo Sair
    Resume
End Sub
Ela vinha funcionando normalmente até que resolveu parar. Simplesmente recortei e colei os campos abaixo da primeira macro, e voltou a funcionar. Alguém sabe me dizer o pq? pois não posso entregar uma planilha com possibilidade deste erro.

obrigado.

Campos que eu recortei e colei

logradouro.Value = UCase(Sheets("TEMP").Range("G1"))
bairro.Value = UCase(Sheets("TEMP").Range("E1"))
cidade.Value = UCase(Sheets("TEMP").Range("D1"))
uf.Value = UCase(Sheets("TEMP").Range("C1"))
Avatar do usuário
Por Reinaldo
Avatar
#17482
Lembrando que a base CEP e um produto comercializado pelo Correio, sendo vedada sua distribuição.
Talvez o problema esteja na capacidade de processamento do site em questão. Veja que nesse mesmo site e recomentado utilizar a consulta em base local, isso evita constantes acessos e consequente "queda" do servico
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord