PDA

View Full Version : click website link



geebee
09-04-2008, 01:17 PM
hi,

i have the following:



Option Explicit
Dim THandle As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal _
hwnd As Long) As Long

Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow _
Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3

Dim myIE As New InternetExplorer


Sub SEC()

'This project includes references to "Microsoft Internet Controls" and
'"Microsoft HTML Object Library"
'Variable declarations
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myURL33 As String

Dim myDoc As HTMLDocument
Dim strSearch As String
'Set starting URL and search string
myURL = https:... secure.site.com/transactions and .asp
strSearch = "usernamer"
'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True
'Wait for the page to load
Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
'Set IE document into object
Set myDoc = myIE.document


Dim strpassword As String
strpassword = "something"
'myDoc.forms(0).UserId.Text = strSearch
With myDoc.getElementsByName("UserName")(0)
.Value = strSearch
End With

'myDoc.forms(0).Password.Value = "userthing"
'With IE.getElementsByName("Password")(0)
With myDoc.getElementsByName("Password")(0)
.Value = strpassword
End With

'myDoc.forms(0).client.Value = "FD"
With myDoc.getElementsByName("Client")(0)
.Value = "CARS"
End With


'******************************************************
'put the focus on the IE window/SECURE, and simulate hitting ENTER key
'note because this code puts the focus on the IE application/window,
'you cannot step through the code to see it work. you have to RUN the code
'******************************************************
Dim lHwnd As Long
lHwnd = FindWindow("IEFrame", vbNullString) 'determine if there is IE open
'MsgBox Windows.Application
If lHwnd <> 0 Then
'MsgBox "IE is open!", vbInformation, "IE"
ShowWindow lHwnd, SW_SHOWNORMAL
Dim XT As Long
XT = BringWindowToTop(lHwnd) 'brings the IE window to top
Windows.Application.SendKeys "{ENTER}"
SendKeys "{ENTER}"
Else
MsgBox "IE isn't open!", vbInformation, "Window not found."
End If
'******************************************************
'end of put the focus on the IE window/SECURE, and simulate hitting ENTER key
'******************************************************


'Wait for the page to load
Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop


End Sub


the preceding code fills out a login screen and then results in landing on the splash/menu page. what i am having trouble coming up with is going from here to simulate clicking on a "view reports" link within the page landed on. any help would be GREATLY appreciated.

thanks in advance,
geebee

mdmackillop
09-05-2008, 03:56 AM
Please use the VBA button to format code as shown.

geebee
09-05-2008, 05:55 AM
i have attached a spreadsheet example so that someone can help me with this code. there is one module in the example. just not sure what to add to it...

thanks in advance,
geebee

mdmackillop
09-05-2008, 09:07 AM
No attachment.

geebee
09-08-2008, 09:22 AM
Option Explicit
Dim THandle As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal _
hwnd As Long) As Long

Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow _
Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3

Dim myIE As New InternetExplorer


Sub SEC()

'This project includes references to "Microsoft Internet Controls" and
'"Microsoft HTML Object Library"
'Variable declarations
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myURL33 As String

Dim myDoc As HTMLDocument
Dim strSearch As String
'Set starting URL and search string
myURL = "secure.site.com/transactions.asp"
strSearch = "usernamer"
'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True
'Wait for the page to load
Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
'Set IE document into object
Set myDoc = myIE.document


Dim strpassword As String
strpassword = "something"
'myDoc.forms(0).UserId.Text = strSearch
With myDoc.getElementsByName("UserName")(0)
.Value = strSearch
End With

'myDoc.forms(0).Password.Value = "userthing"
'With IE.getElementsByName("Password")(0)
With myDoc.getElementsByName("Password")(0)
.Value = strpassword
End With

'myDoc.forms(0).client.Value = "FD"
With myDoc.getElementsByName("Client")(0)
.Value = "CARS"
End With


'******************************************************
'put the focus on the IE window/SECURE, and simulate hitting ENTER key
'note because this code puts the focus on the IE application/window,
'you cannot step through the code to see it work. you have to RUN the code
'******************************************************
Dim lHwnd As Long
lHwnd = FindWindow("IEFrame", vbNullString) 'determine if there is IE open
'MsgBox Windows.Application
If lHwnd <> 0 Then
'MsgBox "IE is open!", vbInformation, "IE"
ShowWindow lHwnd, SW_SHOWNORMAL
Dim XT As Long
XT = BringWindowToTop(lHwnd) 'brings the IE window to top
Windows.Application.SendKeys "{ENTER}"
SendKeys "{ENTER}"
Else
MsgBox "IE isn't open!", vbInformation, "Window not found."
End If
'******************************************************
'end of put the focus on the IE window/SECURE, and simulate hitting ENTER key
'******************************************************


'Wait for the page to load
Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop


End Sub