Preencher formulário da web via código VBA

k7jhow

30-11-2017 12:49:36

Pessoal, é o seguinte:

Estou precisando preencher uma guia de recolhimento de tributos, a CFEM, disponível na internet, via código VBA, mas não estou conseguindo.
Até o momento tenho o seguinte código:


Sub EMISSÃOGUIACFEM()

Dim IE As Object
Dim i As Long
Dim TOTAL As Long
Dim OPCAO_TOMADOR As String
Dim PAI As Object
Dim Link As String

Sheets("BASETOMADO").Select

x = 3


Do While Excel.Cells(x, 1) <> ""

Link = Excel.Cells(x, 1)
CNPJ = Excel.Cells(x, 2)
PROCESSO = Excel.Cells(x, 3)
SUBSTÂNCIA = Excel.Cells(x, 4)
MUNICIPIO = Excel.Cells(x, 5)
APURAÇÃO = Excel.Cells(x, 6)
SAIDAPORVENDA = Excel.Cells(x, 7)
QUANTIDADE = Excel.Cells(x, 8)
ICMS = Excel.Cells(x, 9)
PIS = Excel.Cells(x, 10)
COFINS = Excel.Cells(x, 11)

Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True

Sheets("BASETOMADO").Select

IE.navigate Link


'Loops enquanto a IE está ocupado
Do While IE.busy
Loop

Do While IE.readystate <> 4
DoEvents
Loop

'CNPJ
IE.Document.All("cpfCnpj").innertext = CNPJ



'PROCESSO
IE.Document.All("cbProcesso").innertext = PROCESSO



Porém o processo somente consigo preencher depois que o campo CNPJ fique ATIVO.


Poderiam me ajudar ?


Segue o link do site: https://app.dnpm.gov.br/BoletosCFEM/NaoDivida/CFEM


Obrigado