Notifications
Clear all

Login VBA e HTML

2 Posts
2 Usuários
0 Reactions
1,282 Visualizações
(@candioti)
Posts: 0
New Member
Topic starter
 

Boa tarde,

Pessoal estou tentando fazer o VBA conversar com o HTML em uma tentativa de fazer login em um link intranet, mas está sempre retornando algum erro 424 entre outros e não consigo acertar. Tentei de várias formas fazer o textbox receber o valor da variável MyLogin, desde já agradeço a ajuda.

Sub Login()

Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim Document As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.navigate (" http://hor-miirfprd:50000/XMII/CM/RF/Relatorios/RelatorioDeConferencia/relatorioConferencia.irpt")
IE.Visible = True

MyLogin = "nome"
MyPass = "senha"

Do Until IE.ReadyState = READYSTATE_COMPLETE
Loop

IE.Document.getElementById ["logonForm"].j_username.Value = MyLogin

 
Postado : 30/09/2016 2:21 pm
(@mikel-silveira-fraga)
Posts: 41
Trusted Member
 

Candioti, bom dia e bem vindo ao fórum.

Tente substituir o comando abaixo:

IE.Document.getElementById ["logonForm"].j_username.Value = MyLogin

Por este:

Set objCollection = IE.Document.getElementsByTagName("input")
For Each objElement In objCollection
  If objElement.Id = "logonuidfield" Then objElement.innerText = MyLogin
  ' ou
  ' If objElement.Name = "j_username" Then objElement.innerText = MyLogin
Next objElement

Na primeira opção, o teste lógico é feito Atributo Id do Input Text (caixa de texto usuário) e, na segunda opção, utiliza o Atributo Name.

Teste e retorne se a função funcionou da forma que precisava.

Abraços e excelente semana.

 
Postado : 04/10/2016 6:06 am