Vídeo recomendado
https://youtu.be/diWPPPhW-9E

Interação VBA com Internet Explorer (dúvidas)

Perguntas e Repostas sobre os artigos, posts e arquivos que são postados no site
Wild Wolf
Colaborador
Colaborador
Mensagens: 10
Registrado em: Ter Mar 01, 2011 4:08 pm

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por Wild Wolf »

Bom dia,
Todos os dias preciso de pegar a contagem de páginas impressas no decorrer do dia para acompanhamento de impressão aqui na empresa onde trabalho.

Mas as impressoras já possuem uma placa de rede que me permite obter essas informações via brownser.

Eu preciso justamente do processo inverso do que o pessoal mencionou antes, ao invés de passar uma informação para o site eu preciso obter uma informação do site.

Preciso da informação contida em Page Counter, que nesse caso é 369902.

O Código-Fonte do site é o seguinte:

Código: Selecionar todos

<HTML>
<!--All Rights Reserved. Copyright(C) 2000-2005 Brother Industries, Ltd.-->

<HEAD>
<TITLE>
Brother MFC-8860DN
</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<LINK REL=STYLESHEET TYPE="text/css" Href="../common/mfcweb.css"></HEAD><BODY topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><A NAME="top"></A><DIV CLASS="headinfo">
<TABLE height=122 cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD width=20></TD><TD vAlign=top align=left><IMG src="/pbio/brother.gif" height=52 width=144 border=0><BR>


<IMG src="/common/image/mfc8860dn.gif" border=0>

</TD><TD valign=top align=center><TABLE cellSpacing=0 cellPadding=0 border=0><TR><TD VALIGN="top"><TABLE cellSpacing=2 cellPadding=0 border=0><TR><TD noWrap CLASS="headtd"><A HREF="/main/main.html" CLASS="heada">
<img src="/common/image/ball.gif" border=0 width=15 height=11>

Home Page
</A></TD></TR><TR><TD noWrap CLASS="headtd"><A HREF="/etc/mnt_info.html?kind=item" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Maintenance Information
</A></TD></TR><TR><TD noWrap CLASS="headtd"><A HREF="/list/lists_reports.html" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Lists/Reports
</A></TD></TR>


<TR><TD noWrap CLASS="headtd"><A HREF="/pbio/find.html" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Find Device
</A></TD></TR></TABLE></TD><TD><TABLE cellSpacing=2 cellPadding=0 border=0><TR>



<TD ROWSPAN=4>

<A HREF="/pbio/hlp_certify.html"><IMG 
SRC="/pbio/key_user.gif" WIDTH=24 HEIGHT=11 BORDER=0 ALT="Help" ><BR><IMG 
SRC="/pbio/bar_v.gif" WIDTH=24 HEIGHT=45 BORDER=0 ALT="Help" ><BR><IMG 
SRC="/pbio/bar_h.gif" WIDTH=24 HEIGHT=1 BORDER=0 ALT="Help" ><BR>

</A></TD>

<TD noWrap CLASS="headtd"><A HREF="/fax/general_setup.html?kind=item" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
General Setup
</A></TD></TR>

<TR><TD noWrap CLASS="headtd"><A HREF="/fax/fax_settings.html" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Fax Settings
</A></TD></TR>


<TR><TD noWrap CLASS="headtd"><A HREF="/net/internet_settings.html" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
I-Fax Settings
</A></TD></TR>

<TR><TD noWrap CLASS="headtd"><A HREF="/fax/copy_settings.html?kind=item" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Copy Settings

</A></TD></TR><TR><TD ROWSPAN=2><A HREF="/pbio/hlp_certify.html"><IMG 
SRC="/pbio/key_admin.gif" WIDTH=24 HEIGHT=11 BORDER=0 ALT="Help"><BR><IMG 
SRC="/pbio/bar_v.gif" WIDTH=24 HEIGHT=15 BORDER=0 ALT="Help"><BR><IMG 
SRC="/pbio/bar_h.gif" WIDTH=24 HEIGHT=1 BORDER=0 ALT="Help"><BR>
</A></TD><TD noWrap CLASS="headtd"><A HREF="/admin/administrator_settings.html" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Administrator Settings
</A></TD></TR><TR><TD noWrap CLASS="headtd"><A HREF="/bio/main.html" CLASS="heada"><img src="/common/image/ball.gif" border=0 width=15 height=11>
Network Configuration
</A></TD></TR></TABLE></TD><TD width=20></TD><TD><A HREF="/pbio/hlp_certify.html"><IMG 
SRC="/common/image/key_help.gif" WIDTH=36 HEIGHT=39 BORDER=0 ALT="Help"></A>
</TD></TR></TABLE></TD><TD valign=top align=right>
<IMG SRC="/common/image/spacer.gif" HEIGHT=10>
<BR>



<A HREF="http://solutions.brother.com/cgi-bin/solutions.cgi?MDL=mfc112&LNG=pt&SRC=DEVICE">
<IMG src="/pbio/model_s.gif" height=45 width=144 alt="BROTHER" border=0 ></A>

</TD><TD width=20></TD></TR></TBODY></TABLE>

</DIV><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%" HEIGHT="100%"><TR><TD ALIGN="CENTER" VALIGN="TOP"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=550><TR><TD><FORM ACTION="/etc/mnt_info_post.html" METHOD="POST" NAME="SETUP">
<TABLE CLASS="TagFocus" BORDER=0 CELLPADDING=24 CELLSPACING=0 WIDTH="100%"><TR><TD VALIGN="middle"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%"><TR><TD CLASS="PageTitle">
Maintenance Information
</TD></TR><TR><TD COLSPAN=2><HR></TD></TR><TR><TD COLSPAN=2 ALIGN="CENTER"><TABLE BORDER=0 CELLPADDING=1 CELLSPACING=10><TR><TD CLASS="item">
Node Information 
</TD></TR><TR><TD CLASS="item"><DD>
Model Name 
</DD></TD><TD CLASS="elem">
Brother MFC-8860DN
</TD></TR><TR><TD CLASS="item"><DD>
Serial no. 
</DD></TD><TD CLASS="elem">
G6J215034
</TD></TR><TR><TD CLASS="item"><DD>


MFC&nbsp;

Firmware Version 
</DD></TD><TD CLASS="elem">
H
</TD></TR><TR><TD CLASS="item"><DD>NIC&nbsp;
Firmware Version 
</DD></TD><TD CLASS="elem">
1.12
</TD></TR><TR><TD CLASS="item"><DD>
Memory Size 
</DD></TD><TD CLASS="elem">
32
Mbytes
</TD></TR><TR><TD CLASS="item">
Device Status 
</TD></TR><TR><TD CLASS="item"><DD>
Page Counter 

</DD></TD><TD CLASS="elem">
369902
</TD></TR><TR><TD CLASS="item"><DD>
Drum Count 
</DD></TD><TD CLASS="elem">
31045
</TD></TR><TR><TD CLASS="item">
Toner Information 
</TD></TR><TR><TD CLASS="item"><DD>
Number of times replaced 
</DD></TD><TD CLASS="elem">
77
</TD></TR><TR><TD CLASS="item">
Drum Information 
</TD></TR><TR><TD CLASS="item"><DD>
Estimated Pages Remaining* 
</DD></TD><TD CLASS="elem">

0
pages
</TD></TR><TR><TD CLASS="item"><DD>
(% of Life Remaining)* 
</DD></TD><TD CLASS="elem">
(0.00%)
</TD></TR><TR><TD CLASS="item"><DD>
Number of times replaced 
</DD></TD><TD CLASS="elem">
15
</TD></TR><TR><TD CLASS="item">
Total Pages Printed
</TD></TR>


<TR><TD CLASS="item"><DD>
Fax
</DD></TD><TD CLASS="elem">

5222
pages
</TD></TR>

<TR><TD CLASS="item"><DD>
Copy
</DD></TD><TD CLASS="elem">
134643
pages
</TD></TR><TR><TD CLASS="item"><DD>
PC Print
</DD></TD><TD CLASS="elem">
230036
pages
</TD></TR><TR><TD CLASS="item">
Total Pages Scanned
</TD></TR>


<TR><TD CLASS="item"><DD>

ADF**
</DD></TD><TD CLASS="elem">
103824
pages
</TD></TR>



<TR><TD CLASS="item"><DD>
Flatbed
</DD></TD><TD CLASS="elem">
25782
pages
</TD></TR>

<TR><TD CLASS="item">
Total Paper Jams
</TD><TD CLASS="elem">
980

</TD></TR>


<TR><TD CLASS="item"><DD>
Jam MP Tray
</DD></TD><TD CLASS="elem">
1
</TD></TR>

<TR><TD CLASS="item"><DD>
Jam Tray #1
</DD></TD><TD CLASS="elem">
843
</TD></TR>


<TR><TD CLASS="item"><DD>

Jam Tray #2
</DD></TD><TD CLASS="elem">
0
</TD></TR>

<TR><TD CLASS="item"><DD>
Jam Inside
</DD></TD><TD CLASS="elem">
92
</TD></TR><TR><TD CLASS="item"><DD>
Jam Rear
</DD></TD><TD CLASS="elem">
19
</TD></TR>


<TR><TD CLASS="item"><DD>

Jam Duplex
</DD></TD><TD CLASS="elem">
25
</TD></TR>

<TR><TD CLASS="item">
Total Paper Jams (ADF)**
</TD><TD CLASS="elem">
541
</TD></TR><TR><TD CLASS="elem">
*Based on A4/Letter printing
</TD></TR><TR><TD CLASS="elem">
**Automatic Document Feeder
</TD></TR></TABLE></TD></TR><TR><TD COLSPAN=2><HR></TD></TR>

<TR><TD COLSPAN=2>
Convert this Maintenance Information page to CSV file format.&nbsp;&nbsp;

You can use and save to CSV file format by the WEB browser software now in you are using.
<DIV ALIGN="center">
<INPUT TYPE="submit" VALUE=" Submit ">
</DIV></TD></TR>

</TABLE></TD></TR></TABLE></FORM></TD></TR><TR><TD HEIGHT=10></TD></TR><TR><TD ALIGN="right"><A HREF="#top">
<IMG SRC="/pbio/backtop.gif" WIDTH=19 HEIGHT=18 border=0></A>
</TD></TR></TABLE></TD></TR><TR><TD VALGN="bottom">

<TABLE BORDER="0" WIDTH="100%" CELLSPACING=0 CELLPADDING=0 HEIGHT="43">
<TR BGCOLOR="#000066" ALIGN="CENTER" VALIGN="TOP"> 
<TD><FONT COLOR="#FFFFFF"><BR>All Rights Reserved.Copyright(C) 2000-2006 Brother Industries, Ltd.</FONT></TD>
</TR>
</TABLE>
</TD></TR></TABLE></BODY></HTML>


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Avatar do usuário
webmaster
Administrador
Mensagens: 3114
Registrado em: Sex Jul 24, 2009 2:44 pm
Contato:

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por webmaster »

Wolf,

Use os códigos dos posts anteriores, mas ao invés de atribuir, colete:

Atribuição:

Código: Selecionar todos

oWeb.Document.frames(1).Document.all("NOME_DO_CAMPO").innerText = Variavel
Coleta:

Código: Selecionar todos

Variavel = oWeb.Document.frames(1).Document.all("NOME_DO_CAMPO").innerText
Simples não? No caso, é preciso saber onde está a informação que quer.

Abraços


Avatar do usuário
joseA
Jedi
Jedi
Mensagens: 1048
Registrado em: Qui Out 22, 2009 7:22 am
Localização: Cel. Fabriciano - MG

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por joseA »

Gostaria de um procedimento que acesse a página GoogleMaps http://maps.google.com.br/maps?hl=pt-br&tab=wl inserir na caixa de pesquisa o dado do TextBox1 e ocultar o painél "Como chegar Meus Mapas"

Seria possivel??


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Avatar do usuário
joseA
Jedi
Jedi
Mensagens: 1048
Registrado em: Qui Out 22, 2009 7:22 am
Localização: Cel. Fabriciano - MG

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por joseA »

Na verdade, apenas queria um procedimento que abrisse a página do GoogleMaps e inserisse na caixa de pesquisa um critério, suponhamos "Rua Pernambuco, Belo Horizonte - Minas Gerais" e ocultar o painél "Como chegar Meus Mapas". Teria como?


Avatar do usuário
webmaster
Administrador
Mensagens: 3114
Registrado em: Sex Jul 24, 2009 2:44 pm
Contato:

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por webmaster »

Jose,

Pode aproveitar o mesmo código, com a diferença de que, ao invés de trabalhar no componente Browser no Userform, usar no objeto IE apontado o endereço para tal, no caso, com o método Navigate.

Creio ser simples com os exemplos e códigos que temos aqui, certo?

Abraços


Avatar do usuário
joseA
Jedi
Jedi
Mensagens: 1048
Registrado em: Qui Out 22, 2009 7:22 am
Localização: Cel. Fabriciano - MG

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por joseA »

Tomás,

Conseguí esse código, ele abre a página do GoogleMaps mas não insere o critério de pesquisa no campo e nem oculta o painél. Confira:

Código: Selecionar todos

Public Sub ConectaWeb()
On Error Resume Next
Dim endereço As String
Dim mostra As Boolean

Dim i, n, x As Integer
endereço = "http://maps.google.com.br/maps?hl=pt-br&tab=wl"
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate (endereço)
While ie.ReadyState <> 1
Wend
ie.Visible = True
ie.document.forms.Item(0).Item(4).Value = "Rua Pernambuco, Belo Horizonte - Minas Gerais"
ie.document.forms.Item(0).submit
  
While ie.ReadyState <> 1
Wend
End Sub


Wild Wolf
Colaborador
Colaborador
Mensagens: 10
Registrado em: Ter Mar 01, 2011 4:08 pm

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por Wild Wolf »

joseA escreveu:Tomás,

Conseguí esse código, ele abre a página do GoogleMaps mas não insere o critério de pesquisa no campo e nem oculta o painél. Confira:

Código: Selecionar todos

Public Sub ConectaWeb()
On Error Resume Next
Dim endereço As String
Dim mostra As Boolean

Dim i, n, x As Integer
endereço = "http://maps.google.com.br/maps?hl=pt-br&tab=wl"
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate (endereço)
While ie.ReadyState <> 1
Wend
ie.Visible = True
ie.document.forms.Item(0).Item(4).Value = "Rua Pernambuco, Belo Horizonte - Minas Gerais"
ie.document.forms.Item(0).submit
  
While ie.ReadyState <> 1
Wend
End Sub
joseA,

Acredito que esse código vá te ajudar:

Código: Selecionar todos

Public Sub ConectaWeb()
    On Error Resume Next
    Dim endereço As String
    Dim mostra As Boolean

    Dim i, n, x As Integer
    URL = ("http://maps.google.com.br/maps?hl=pt-br&q=")
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    endereco = "Rua Pernambuco, Belo Horizonte - Minas Gerais"
    URL = (URL & endereco)
    ie.Navigate (URL)
    End Sub


Avatar do usuário
joseA
Jedi
Jedi
Mensagens: 1048
Registrado em: Qui Out 22, 2009 7:22 am
Localização: Cel. Fabriciano - MG

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por joseA »

Ajudou sim Wild Wolf,

Perfeitamente dentro do propósito.

Muito obrigado.


dantunes
Acabou de chegar
Acabou de chegar
Mensagens: 4
Registrado em: Seg Jun 13, 2011 9:56 am

Re: Interação VBA com Internet Explorer (dúvidas)

Mensagem por dantunes »

Bom dia pessoal,

Sou mais um entusiasta do VBA precisando de ajuda. Vou passar o problema:

1 - Como estou mostrando abaixo, o programador usou a mesma nomeclatura para o ID no ul e no Input.

<div id="localidade">
<form action="?i=notam&busca=localidade" id="notam" method="post">
<p>Insira os Indicadores de Localidade<br />
<span><a id="mais">Descubra os indicadores de localidade</a></span></p>
<ul id="codigo">
<li>
<input id="codigo" maxlength="74" style="width:380px;" type="text" name="codigo" />
</li>

Isto está impossibilitando o preenchimento automático no site: http://www.aisweb.aer.mil.br/?i=notam.

O código basico ie.Document.all("codigo").innerText = X está identificando o ul. Não estou conseguinto chegar até a caixa para preencher.

Se alguem tiver alguma idéia !?

Atenciosamente.


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Responder