OK,
So I think I've found a potential solution to a problem I mentioned yesterday
<https://access-programmers.co.uk/forums/showthread.php?t=292474>
Using the code below as an example, how can I:
1) trigger the "save as" option (Ctrl S i believe) , then
2) send Ctrl C for copy, as once save as is clicked the filename is provided and highlighted
I've tried sendKeys, but it does not work as expected. Also, I am concerned that it I am doing anything else while the program is running, sendKeys will not work as expected anyway.
Thank you
So I think I've found a potential solution to a problem I mentioned yesterday
<https://access-programmers.co.uk/forums/showthread.php?t=292474>
Using the code below as an example, how can I:
1) trigger the "save as" option (Ctrl S i believe) , then
2) send Ctrl C for copy, as once save as is clicked the filename is provided and highlighted
I've tried sendKeys, but it does not work as expected. Also, I am concerned that it I am doing anything else while the program is running, sendKeys will not work as expected anyway.
Thank you
Code:
Public Sub Example01()
Dim dbsSCF As DAO.Database
Dim rstSCF As DAO.Recordset
Set dbsSCF = CurrentDb
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
' Not necessary, but this is the web page where the file link exists
IE.Navigate ("https://cran.r-project.org/package=abc")
'Wait while the page loads
Dim sw As StopWatch
Set sw = New StopWatch
sw.StartTimer
Do While (IE.Busy Or IE.ReadyState <> 4)
If sw.EndTimer / 1000 > 60 Then
MsgBox "Webpage taking too long to load; please check connection and try again."
Exit Sub
End If
Loop
' Note: this is a stupid example bacause the file name is part of the URL
' The real example I am looking at does not have the file name as part of the URL
IE.Navigate ("https://cran.r-project.org/web/packages/abc/../../../bin/windows/contrib/3.4/abc_2.1.zip")
'This doesn't trigger "save as"
SendKeys "^{S}"
'IE.Quit
'Set IE = Nothing
End Sub