Hi
I'm wanting to set up the following process
1) Use windows scheduler to open up a workbook every morning at 8am (ACTIONED)
2) Use "Sub Auto_Open" to run my code (ACTIONED)
3) The code to run reads a page from a wesbite site via an Excel webquery (one webquery in DataSet1 tab and one in DataSet2 tab)
I think I've got it to work (see code below) but have just read that send keys does not work when the screen is locked
Can you help me with the correct code to do what I need?
Many thanks for reading
Sub Auto_Open()
Authenticate_Login1
End Sub
Sub Authenticate_Login1()
Sheets("DataSet1").Select
Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
'Application.Wait (Now + TimeValue("0:00:30"))
ie.NAVIGATE "http://app.mediaplex.com/reports/bl_template.get_web_query?rtid_in=1010687"
'DoEvents
'Application.Wait (Now + TimeValue("0:01:00"))
Application.SendKeys "{TAB}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{ENTER}", True
'SendKeys "{TAB}", True
'SendKeys "{ENTER}", True
'DoEvents
part_1
End Sub
Sub part_1()
Dim n As Integer
n = 10
'Range("A1").Select
Sheets("DataSet1").Range("A1").QueryTable.Refresh BackgroundQuery:=False
Sheets("DataSet2").Range("A1").QueryTable.Refresh BackgroundQuery:=False
'ActiveWorkbook.RefreshAll
Application.SendKeys "{TAB}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{ENTER}", True
Do
Application.ScreenUpdating = True
If Sheets("DataSet1").Range("A3").Value = "" Or Sheets("DataSet2").Range("A3").Value = "" Then
n = n + 1
Application.Wait (Now + TimeValue("0:00:30"))
Else
n = 1
End If
'Loop Until Application.StatusBar = "Ready"
Loop Until n = 1
'DoEvents
'Application.Wait (Now + TimeValue("0:01:00"))
'Loop Until Application.StatusBar = "Ready"
Save_files 'runs a separate to save files to particular part of network, Ive not include this code in this post as this works ok...)
ActiveWorkbook.Save
Application.ScreenUpdating = True
Sheets("DataSet1").Select
MsgBox "Files saved..."
Bookmarks