Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_MAXIMIZE = 3
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Sub website()
Dim objIe As Object
Set objIe = CreateObject("InternetExplorer.Application")
objIe.Visible = True
apiShowWindow objIe.hwnd, SW_MAXIMIZE
www = "http://address.com"
objIe.navigate www
With objIe
Do While .Busy Or .readyState <> 4
Loop
Set Element = .document.getElementsByName("login")
Element.Item(0).Value = "UserName"
Set Element = .document.getElementsByName("password")
Element.Item(0).Value = "YourPassword"
Set Element = .document.getElementsByName("login_ldap")
.document.getElementById("login_ldap").Click
.document.forms(0).submit
End With
End Sub
Dim scheduledtime As Double</>
Sub eSite(adres As String, row As Integer, col As Integer)
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Visible = False
ie.Navigate adres
Do While ie.ReadyState <> 4
DoEvents
Loop
DoEvents
For Each el In ie.Document.all
If el.classname = "Value" Or el.classname = "Value2" Then
Cells(row, col) = el.innertext / 1
row = row + 1
End If
Next
ie.Quit
Set ie = Nothing
Application.OnTime Now + TimeValue("00:00:10"), "Main"
End Sub
Sub Start()
scheduledtime = Now + TimeValue("00:00:10")
Application.OnTime scheduledtime, "eSite"
End Sub
Sub StopMacro()
On Error Resume
Application.OnTime EarliestTime:=scheduledtime, Procedure:="eSite", schedule:=False
End Sub
' Needed references: Microsoft HTML Object Library and Microsoft Internet Controls
Sub ScriptBot()
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.Visible = True
objIE.navigate "https://www.sitename.com"
On Error GoTo errorhandler
i = 1
Do While i < 200
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.querySelector("input[type=button]").Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
Cells(i, 1) = objIE.document.querySelector("div[class=marginesy]").innerText
Cells(i, 1).Offset(0, 1) = objIE.document.querySelector("div[id=""odpowiedz1""]").innerText
objIE.document.querySelector("input[value=""Następne pytanie""]").Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
i = i + 1
Loop
errorhandler:
objIE.Quit
End Sub