Error in macro execution in Libreoffice

Asked

Viewed 100 times

-1

Good morning.

I am trying to run the following macro in Libreoffice Calc:

Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Sub busca_cep()

Range("B3:D3").ClearContents

Set ie = CreateObject("internetexplorer.application")

ie.navigate "http://www.buscacep.correios.com.br/sistemas/buscacep/"
ie.Visible = True

Do While ie.busy And ie.readyState <> "READYSTATE_COMPLETE"
DoEvents
Loop

ie.document.getElementsByTagName("input")(0).Value = Cells(3, 1).Value
ie.document.getElementsByClassName("btn2 float-right")(0).Click

Do While ie.busy And ie.readyState <> "READYSTATE_COMPLETE"
DoEvents
Loop

Cells(3, 2) = ie.document.getElementsByTagName("td")(0).innertext
Cells(3, 3) = ie.document.getElementsByTagName("td")(1).innertext
Cells(3, 4) = ie.document.getElementsByTagName("td")(2).innertext

ie.Quit

Range("A3:D3").WrapText = False

End Sub

But on line 16:

ie.document.getElementsByTagName("input")(0).Value = Cells(3, 1).Value

Displays the following error message:

Erro de execução do BASIC.
'1'

Type: com.sun.star.lang.WrappedTargetRuntimeException
Message: [automation bridge] unexpected exception in IUnknownWrapper::invokeGetProperty ! 
Message : 
[automation bridge]Property "getElementsByTagName" is not supported

Could you help me?

  • Support for Microsoft VBA in Libreoffice is limited. See: https://help.libreoffice.org/6.2/pt-BR/text/sbasic/shared/vbasupport.html. It is possible to translate to Libreoffice Basic?

1 answer

0

When I execute the macro an error occurs in this part:

ie.document.getElementsByClassName("btn2 float-right")(0).Click

inserir a descrição da imagem aqui

Browser other questions tagged

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