Spikehunter
New Member
- Joined
- Sep 27, 2023
- Messages
- 1
- Office Version
- 365
- 2019
- Platform
- Windows
I have built a spreadsheet that uses the follow hyperlink method to load a Web page. Works well except for one small glitch. If chrome is not open the "send keys" doesn't work, even though I can do it manually, and with a delay of 60 seconds. The next time I try it works perfectly and also for other associated pages. It's as though something isn't being set first time through the page loading. My programming experience is from the 70's so not quite up to date. I have a workaround but its not very elegant and I don't want to use IE.
Any suggestions gratefully received as I have tried many thoughts and other ideas.
Sub Update_IG_Availability_Data()
'
' Paste_New_Data Macro
'
On Error GoTo Error_Routine
Application.CutCopyMode = False
Call ClearClipboard
Dim URL As String
URL = "https://address"
ActiveWorkbook.FollowHyperlink URL
Application.Wait (Now() + TimeValue("00:00:15")) 'has been tested upto 55 seconds
SendKeys ("^a^c")
ThisWorkbook.Sheets("InputData").Activate
Range("A1:D4").Select
AppActivate ActiveWindow.Caption
CarryOn = MsgBox("Do you want to Paste the new data?", vbYesNo, " Availability")
If CarryOn = vbYes Then
CheckClipboard
ActiveSheet.Paste Destination:=Worksheets("InputData").Range("A1")
End If
CarryOn = MsgBox("Do you want to update the data?", vbYesNo, "BBGC")
If CarryOn = vbYes Then
UpdateAvailability
End If
Range("A1").Select
Exit Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error_Routine:
'MsgBox ("You have an error, Have you copied the IG Data before running")
CarryOn = MsgBox("Do you want to try again", vbYesNo, "Burnham & Berrow Golf Club Availability")
If CarryOn = vbYes Then
Update_IG_Availability_Data
End If
End Sub
Any suggestions gratefully received as I have tried many thoughts and other ideas.
Sub Update_IG_Availability_Data()
'
' Paste_New_Data Macro
'
On Error GoTo Error_Routine
Application.CutCopyMode = False
Call ClearClipboard
Dim URL As String
URL = "https://address"
ActiveWorkbook.FollowHyperlink URL
Application.Wait (Now() + TimeValue("00:00:15")) 'has been tested upto 55 seconds
SendKeys ("^a^c")
ThisWorkbook.Sheets("InputData").Activate
Range("A1:D4").Select
AppActivate ActiveWindow.Caption
CarryOn = MsgBox("Do you want to Paste the new data?", vbYesNo, " Availability")
If CarryOn = vbYes Then
CheckClipboard
ActiveSheet.Paste Destination:=Worksheets("InputData").Range("A1")
End If
CarryOn = MsgBox("Do you want to update the data?", vbYesNo, "BBGC")
If CarryOn = vbYes Then
UpdateAvailability
End If
Range("A1").Select
Exit Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error_Routine:
'MsgBox ("You have an error, Have you copied the IG Data before running")
CarryOn = MsgBox("Do you want to try again", vbYesNo, "Burnham & Berrow Golf Club Availability")
If CarryOn = vbYes Then
Update_IG_Availability_Data
End If
End Sub