VBA send keys for "save as" then (1 Viewer)

Patrick77

New member
Local time
Today, 05:31
Joined
Mar 7, 2017
Messages
6
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


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
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 12:31
Joined
Jul 9, 2003
Messages
16,245
I haven't examined your code so advice might not be much use. However I recall the general advice is to avoid using sendkeys. I would suggest that you find an alternative if possible.
 

Users who are viewing this thread

Top Bottom