Vídeo recomendado
https://youtu.be/diWPPPhW-9E
https://youtu.be/diWPPPhW-9E
Dúvida no VBA
-
- Colaborador
- Mensagens: 10
- Registrado em: Ter Nov 16, 2010 3:50 pm
Re: Dúvida no VBA
Eu consegui de outro jeito deu mais trabalho mas funcionou, mas eu queria saber como eu faço para poder imprimir a pagina da internet dps?????
Public Sub carregar()
On Error Resume Next
Dim cpf As Single
Dim tempo As Integer
voltar:
Set ie = GetObject("", "InternetExplorer.Application.1")
ie.Visible = True
ie.Navigate "http://sistemas.anac.gov.br/gruinternet ... rvico=1103"
Do While ie.busy
DoEvents
Loop
ie.document.getElementById("cnpjCpf").Value = "07575651000400"
ie.document.getElementById("nomeContribuinte").Value = "VRG Linhas Aereas SA "
ie.document.getElementById("image2").Click
Do While ie.busy
DoEvents
Loop
Do While ie.busy
Loop
ie.document.getElementById("cmd").Click
Do While ie.busy
DoEvents
Loop
Do While ie.busy
Loop
'x = ie.document.frames.Item(0).document.Forms.Length
'x = ie.document.frames.Item(1).document.Forms.Length
ActiveWindow.SelectedSheets.PrintOut , Copies:=1, Collate:=True
End Sub
Abçs
Public Sub carregar()
On Error Resume Next
Dim cpf As Single
Dim tempo As Integer
voltar:
Set ie = GetObject("", "InternetExplorer.Application.1")
ie.Visible = True
ie.Navigate "http://sistemas.anac.gov.br/gruinternet ... rvico=1103"
Do While ie.busy
DoEvents
Loop
ie.document.getElementById("cnpjCpf").Value = "07575651000400"
ie.document.getElementById("nomeContribuinte").Value = "VRG Linhas Aereas SA "
ie.document.getElementById("image2").Click
Do While ie.busy
DoEvents
Loop
Do While ie.busy
Loop
ie.document.getElementById("cmd").Click
Do While ie.busy
DoEvents
Loop
Do While ie.busy
Loop
'x = ie.document.frames.Item(0).document.Forms.Length
'x = ie.document.frames.Item(1).document.Forms.Length
ActiveWindow.SelectedSheets.PrintOut , Copies:=1, Collate:=True
End Sub
Abçs
Re: Dúvida no VBA
Colega,
"dps" seria "depois"? Se sim, coloque depois de tudo o seguinte:
Deve funcionar.
Abraços
"dps" seria "depois"? Se sim, coloque depois de tudo o seguinte:
Código: Selecionar todos
ie.Navigate "javascript:window.print()"
Abraços
-
- Colaborador
- Mensagens: 10
- Registrado em: Ter Nov 16, 2010 3:50 pm
Re: Dúvida no VBA
Não funcionou pq a pagina que abre para imprimir é não é uma pagina da Web "comum" ela abre no formato PDF por isso eu acho que não deu certo.
Abçs
Abçs
Re: Dúvida no VBA
Colega,
Se o resultado for um PDF aberto dentro do navegador, então não dá para garantir a impressão.
Abraços
Se o resultado for um PDF aberto dentro do navegador, então não dá para garantir a impressão.
Abraços
-
- Colaborador
- Mensagens: 10
- Registrado em: Ter Nov 16, 2010 3:50 pm
Re: Dúvida no VBA
É exatamente isso que está acontecendo é um PDF dentro do navegador.... Já que não tem como intaum muito obrigado
Abçs!!!!!!!!!!!!
Abçs!!!!!!!!!!!!
Re: Dúvida no VBA
Estou com o mesmo problema.
Dá o mesmo erro.
tentei fazer alguma alterações mas nada adiantou.
é um vba pra pesquisar cpf na intranet da empresa.
alguem poderia, por favor, ver para mim? não estou conseguindo.
Declare PtrSafe Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub cpf()
matricula = InputBox("Digite sua Matrícula: (c999999)", "Digitar Matrícula")
senha = InputBox("Digite sua senha", "Digitar Senha")
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate2 URL:="http://sipes"
While ie.Busy: Sleep 10: DoEvents: Wend
Do While ie.Document.ReadyState <> "complete": Sleep 10: DoEvents: Loop
Set docweb = ie.Document
docweb.all("username").Value = matricula
docweb.all("password").Value = senha
docweb.all("frmLogin").Submit
While ie.Busy: Sleep 10: DoEvents: Wend
Do While ie.Document.ReadyState <> "complete": Sleep 10: DoEvents: Loop
linha = 2
While Range("A" & linha).Value <> ""
cpfcon = Range("A" & linha).Value
cpfcon = Format(cpfcon, "00000000000")
docweb.all("tpCPF").Value = cpfcon
teste2 = docweb.all("checkall").Value
If teste2 = "Marcar Todas" Then docweb.all("checkall").Click
docweb.all("btConsultar").Click
While ie.Busy: Sleep 10: DoEvents: Wend
Do While ie.Document.ReadyState <> "complete": Sleep 10: DoEvents: Loop
sinad = docweb.getElementsByTagName("table")(16).Rows(0).Cells(0).innerText
cadin = docweb.getElementsByTagName("table")(19).Rows(0).Cells(0).innerText
serasa = docweb.getElementsByTagName("table")(22).Rows(0).Cells(0).innerText
siccf = docweb.getElementsByTagName("table")(25).Rows(0).Cells(0).innerText
spc1 = docweb.getElementsByTagName("table")(28).Rows(0).Cells(0).innerText
If sinad = "" Then sinad = "Consta Ocorrencia"
If cadin = "" Then cadin = "Consta Ocorrencia"
If serasa = "" Then serasa = "Consta Ocorrencia"
If siccf = "" Then siccf = "Consta Ocorrencia"
If spc1 = "" Then spc1 = "Consta Ocorrencia"
Sheets("Plan1").Range("B" & linha).Value = sinad
Sheets("Plan1").Range("C" & linha).Value = cadin
Sheets("Plan1").Range("D" & linha).Value = serasa
Sheets("Plan1").Range("E" & linha).Value = siccf
Sheets("Plan1").Range("F" & linha).Value = spc1
linha = linha + 1
Wend
ie.Quit
MsgBox ("Pronto")
End Sub
Dá o mesmo erro.
tentei fazer alguma alterações mas nada adiantou.
é um vba pra pesquisar cpf na intranet da empresa.
alguem poderia, por favor, ver para mim? não estou conseguindo.
Declare PtrSafe Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub cpf()
matricula = InputBox("Digite sua Matrícula: (c999999)", "Digitar Matrícula")
senha = InputBox("Digite sua senha", "Digitar Senha")
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate2 URL:="http://sipes"
While ie.Busy: Sleep 10: DoEvents: Wend
Do While ie.Document.ReadyState <> "complete": Sleep 10: DoEvents: Loop
Set docweb = ie.Document
docweb.all("username").Value = matricula
docweb.all("password").Value = senha
docweb.all("frmLogin").Submit
While ie.Busy: Sleep 10: DoEvents: Wend
Do While ie.Document.ReadyState <> "complete": Sleep 10: DoEvents: Loop
linha = 2
While Range("A" & linha).Value <> ""
cpfcon = Range("A" & linha).Value
cpfcon = Format(cpfcon, "00000000000")
docweb.all("tpCPF").Value = cpfcon
teste2 = docweb.all("checkall").Value
If teste2 = "Marcar Todas" Then docweb.all("checkall").Click
docweb.all("btConsultar").Click
While ie.Busy: Sleep 10: DoEvents: Wend
Do While ie.Document.ReadyState <> "complete": Sleep 10: DoEvents: Loop
sinad = docweb.getElementsByTagName("table")(16).Rows(0).Cells(0).innerText
cadin = docweb.getElementsByTagName("table")(19).Rows(0).Cells(0).innerText
serasa = docweb.getElementsByTagName("table")(22).Rows(0).Cells(0).innerText
siccf = docweb.getElementsByTagName("table")(25).Rows(0).Cells(0).innerText
spc1 = docweb.getElementsByTagName("table")(28).Rows(0).Cells(0).innerText
If sinad = "" Then sinad = "Consta Ocorrencia"
If cadin = "" Then cadin = "Consta Ocorrencia"
If serasa = "" Then serasa = "Consta Ocorrencia"
If siccf = "" Then siccf = "Consta Ocorrencia"
If spc1 = "" Then spc1 = "Consta Ocorrencia"
Sheets("Plan1").Range("B" & linha).Value = sinad
Sheets("Plan1").Range("C" & linha).Value = cadin
Sheets("Plan1").Range("D" & linha).Value = serasa
Sheets("Plan1").Range("E" & linha).Value = siccf
Sheets("Plan1").Range("F" & linha).Value = spc1
linha = linha + 1
Wend
ie.Quit
MsgBox ("Pronto")
End Sub
Re: Dúvida no VBA
Pessoal, estou tentando o código abaixo, contudo no site http://www.scgas.com.br ele dá erro ja no "Set Doc = ie.Document"
já no site da receita.fazenda.gov.br ele funciona.
Qual seria o problema?
Sub ok()
Dim ie As Object
Dim Doc As IHTMLDocument4
Dim elements As IHTMLElementCollection
Dim Element As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www.scgas.com.br"
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set Doc = ie.Document
Set elements = Doc.getElementsByTagName("input")
For Each Element In elements
Debug.Print Element.Name
Next
Set elements = Nothing
End Sub
já no site da receita.fazenda.gov.br ele funciona.
Qual seria o problema?
Sub ok()
Dim ie As Object
Dim Doc As IHTMLDocument4
Dim elements As IHTMLElementCollection
Dim Element As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www.scgas.com.br"
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set Doc = ie.Document
Set elements = Doc.getElementsByTagName("input")
For Each Element In elements
Debug.Print Element.Name
Next
Set elements = Nothing
End Sub
Re: Dúvida no VBA
Pessoal, estou tentando o código abaixo, contudo no site http://www.scgas.com.br ele dá erro ja no "Set Doc = ie.Document"
já no site da receita.fazenda.gov.br ele funciona.
Qual seria o problema?
Sub ok()
Dim ie As Object
Dim Doc As IHTMLDocument4
Dim elements As IHTMLElementCollection
Dim Element As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www.scgas.com.br"
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set Doc = ie.Document
Set elements = Doc.getElementsByTagName("input")
For Each Element In elements
Debug.Print Element.Name
Next
Set elements = Nothing
End Sub
Acabei de achar a resposta e FUNCIONOU!!!
Apenas desativei o modo protegido dentro das opções de segurança do IE, para quem não quer fazer isso tem outras soluções no link abaixo.
http://stackoverflow.com/questions/1296 ... l-intranet
já no site da receita.fazenda.gov.br ele funciona.
Qual seria o problema?
Sub ok()
Dim ie As Object
Dim Doc As IHTMLDocument4
Dim elements As IHTMLElementCollection
Dim Element As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www.scgas.com.br"
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set Doc = ie.Document
Set elements = Doc.getElementsByTagName("input")
For Each Element In elements
Debug.Print Element.Name
Next
Set elements = Nothing
End Sub
Acabei de achar a resposta e FUNCIONOU!!!
Apenas desativei o modo protegido dentro das opções de segurança do IE, para quem não quer fazer isso tem outras soluções no link abaixo.
http://stackoverflow.com/questions/1296 ... l-intranet