Johnnyv015
New Member
- Joined
- Sep 8, 2014
- Messages
- 11
Hello all, I am fairly new to this whole VBA programing thing. I have used excel for years however never had much of a need for VBA outside of simple "Plug and Dump" button macros.
However I have now found my self working on a large(seems large to me) task of setting up an automated data pull for my employer.
Due to this being sensitive data I am unable to use the actual links I need however I believe I will be able to explain what I need help on.
I need to create a macro(s) that will
1.) Login to our system
2.) follow links once logged in to pull data from 7 different links and pool this data on separate pages
3.) logout once data has been pulled and is complete.
Also this will all have to be automated to repeat this task ever hour on the half hour. (only during business hours.) - I'm thinking a "Start" and "stop" button will be the easiest approach here.
Only other kicker I have is staggering the data pull on the 7 reports so that this does not crash excel.
If anyone can shoot me some code lines or examples of what direction I should start going with this the help would be greatly appreciated. As of now this is what I have
Am I heading in the right direction? I feel lost. Thanks!
However I have now found my self working on a large(seems large to me) task of setting up an automated data pull for my employer.
Due to this being sensitive data I am unable to use the actual links I need however I believe I will be able to explain what I need help on.
I need to create a macro(s) that will
1.) Login to our system
2.) follow links once logged in to pull data from 7 different links and pool this data on separate pages
3.) logout once data has been pulled and is complete.
Also this will all have to be automated to repeat this task ever hour on the half hour. (only during business hours.) - I'm thinking a "Start" and "stop" button will be the easiest approach here.
Only other kicker I have is staggering the data pull on the 7 reports so that this does not crash excel.
If anyone can shoot me some code lines or examples of what direction I should start going with this the help would be greatly appreciated. As of now this is what I have
Code:
Sub Login()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "random url"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.Name.Value = "123456"
HTMLDoc.all.Password.Value = "123456"
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
Resume Next
End Sub