Hi everyone
So this is my question...
I need to log in so many times in so many computers, in a specific web page "http://webshipping.dhl.com.mx"
I wold like to do it with a macro Im using Excel 2003
By now, I have the next code, But doesnt seems to work, please help me... - Sub pag()
-
-
Dim myie As New InternetExplorer 'New'
-
Dim mydoc As HTMLDocument
-
Dim myurl, usuario As String
-
Dim ieform As Object
-
-
myurl = "http://webshipping.dhl.com.mx"
-
usuario = "User"
-
-
myie.navigate myurl
-
myie.Visible = True
-
-
'esperar a que cargue la página
-
Do While myie.Busy Or myie.ReadyState <> READYSTATE_COMPLETE
-
DoEvents
-
Loop
-
-
'MsgBox myie.LocationName
-
-
-
Set mydoc = myie.Document
-
mydoc.forms(0).UserName.Value = usuario ' i get an error here
-
-
' code for set the password must be here
-
-
'code for submit the form is here
-
-
'MsgBox "pausa p/ver si escribió"
-
'mydoc.forms [0].submit
-
-
Do While myie.Busy Or myie.ReadyState <> READYSTATE_COMPLETE
-
DoEvents
-
Loop
-
-
MsgBox myie.LocationName
-
-
-
End Sub
4 2464
To open a webpage in Excel: - Sub launchIE()
-
ActiveWorkbook.FollowHyperlink Address:="http://www.google.ca", NewWindow:=False
-
ActiveWorkbook.FollowHyperlink Address:="http://www.yahoo.ca", NewWindow:=False
-
End Sub
For Your URL it will be: - Sub launchIE()
-
ActiveWorkbook.FollowHyperlink Address"http://webshipping.dhl.com.mx", NewWindow:=False
-
End Sub
danp129 323
Recognized Expert Contributor
Checking to see if the browser is finished is always a pain especially in frames or redirects. I've left your checks but added my own, then showed how to populate the textboxes and submit the form. -
' References: 1) MS Internet Controls. 2) MS HTML Object Library
-
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
-
Const PROCESS_TIMEOUT = 20 ' Seconds to wait for procedure to fail on errors
-
-
Sub pag()
-
Dim StartTime As Date
-
Dim myie As New InternetExplorer 'New'
-
Dim mydoc As HTMLDocument
-
Dim myurl As String
-
Dim ieform As IHTMLFormElement
-
Dim usuario As String
-
Dim Contrasena As String
-
-
StartTime = Now()
-
-
usuario = "User"
-
Contrasena = "Password"
-
-
myurl = "http://webshipping.dhl.com.mx"
-
-
myie.navigate myurl
-
myie.Visible = True
-
-
'esperar a que cargue la página
-
Do While myie.Busy Or myie.ReadyState <> READYSTATE_COMPLETE
-
DoEvents
-
Loop
-
-
' Wait until submit button is found or our process times out
-
Dim testElement As IHTMLElementCollection
-
Do
-
' Look for submit button, exit loop if we find it
-
On Error Resume Next
-
Set mydoc = myie.Document
-
Set testElement = mydoc.getElementById("loginform").getElementsByTagName("input")
-
-
If testElement Is Nothing Then
-
Sleep (100) ' Wait 1/10th second
-
Else
-
' We've found the form and some inputs, if the submit button is found then exit do
-
If LCase(testElement.Item(testElement.Length - 1).Value) = "ingresar" Then Exit Do
-
End If
-
-
' Check time process has taken, if more than user specified, close browser and exit loop
-
If DateDiff("s", StartTime, Now()) >= PROCESS_TIMEOUT Then
-
Set mydoc = Nothing
-
Set testElement = Nothing
-
myie.Quit
-
Set myie = Nothing
-
MsgBox "Failed to login to website, user specified timeout of " & PROCESS_TIMEOUT & " seconds has been exceeded."
-
Exit Sub
-
End If
-
Loop
-
-
On Error GoTo 0
-
-
Dim formInputs As IHTMLElementCollection
-
Set ieform = mydoc.getElementById("loginform")
-
-
ieform("j_username", 0).Value = usuario
-
ieform("j_password", 0).Value = Contrasena
-
ieform.submit
-
-
-
Do While myie.Busy Or myie.ReadyState <> READYSTATE_COMPLETE
-
DoEvents
-
Loop
-
-
MsgBox myie.LocationName
-
-
-
End Sub
-
danp129, you are my hero, it works perfectly, I really appreciate the time you dedicate to reply my question
Thank you so much
Cheers
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Scott |
last post by:
Hi there,
I have a PDF that has editable form fileds. I want to be able dynamically
fill in those form fields based on values I provide to the PDF. Right now, I
can create an instance of the...
|
by: mikeybe |
last post by:
Making a very simple library circulation database for a school
project.
I have a Patron Information table(patronID, first name, last name,
phone) , an item information table (bookID, book title,...
|
by: Joanne Lewis |
last post by:
I am having a great deal of difficulty with a form. Basically, I would
like to enter an account # and have the account #, patient first name,
and patient last name automatically fill.
The form...
|
by: Jason Huang |
last post by:
Hi,
In my C# windows form project, how do I use an existing Excel 2000 as a
template?
Thanks for help.
Jason
|
by: Alex |
last post by:
Hello list
This question has probably already been asked, but let me ask again
I have a mysql database to which I connect with my php scripts. The
database contains articles. Name, Unit_Price...
|
by: limipl |
last post by:
Hello,
How may I pass in VBA a value from a control in a access 2003 form to
a control in a excel 2003 form ?
I try this but it does'nt run: (oApp=word.application)...
|
by: cmcl95 |
last post by:
HI Folks,
I need some help
I'm trying to develop a automated way to import from a excel spsh excluding the 1st 2 rows & two out of 41 columns.
I got the 1st part with range see below
...
|
by: Nosferatum |
last post by:
I tried to combine a script which process a web form and mails the
result, and at the same time stores the entered info into a excel-file
on the server. But I just can't make it work. Does it exist...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
|
by: ghjk |
last post by:
I have table which is clickable.When user click one record I want to call java script function and fill the form using selected values. This is my code and I can't understand what is going...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |