How to click Enter while Excel is waiting for user action?

Viewed 254

When I save my Excel file with VBA, it asks me to enter my credentials (it saves it on some kind of server). Looking though the website I found a way to use SendKeys and delay the action.

My issue:
The code stops and waits for user input (Enter) and I can't find a way to start the next line of code (that is actually the action of pushing Enter...)

My code:
Here is the specific part I need help with:

.SaveAs Filename:="Y:\Must\Must Chart Management.csv", FileFormat:=xlCSV, Local:=True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys ("{ENTER}")

Here is the whole thing:

Sub UpdateMust2020()
    
Application.DisplayAlerts = False
KillFile = "B:\Must\Must Chart Management.csv"

With ActiveWorkbook
    
    Worksheets("Must Chart Management").Activate
        .SaveAs Filename:="Y:\Must\Must Chart Management.csv", FileFormat:=xlCSV, Local:=True
        Application.Wait (Now + TimeValue("0:00:05"))
        SendKeys ("{ENTER}")
        .SaveAs Filename:="E:\users\Must Definition Dashboard\Convergence\Must Chart Management.csv", FileFormat:=xlCSV, Local:=True
        
    Worksheets("MasterQuery").Activate
        .SaveAs Filename:="Y:\Must\Must Statistics Charts.csv", FileFormat:=xlCSV, Local:=True
        .SaveAs Filename:="E:\users\Must Definition Dashboard\Convergence\Must Statistics Charts.csv", FileFormat:=xlCSV, Local:=True
        
    Worksheets("Csv").Activate
        .SaveAs Filename:="Y:\Must\MustWin2020-template.csv", FileFormat:=xlCSV, Local:=True
        .SaveAs Filename:="E:\users\Must Definition Dashboard\Convergence\MustWin2020-template.csv", FileFormat:=xlCSV, Local:=True
        
    Worksheets("Csv for One Industry ALL VIEW").Activate
        .SaveAs Filename:="Y:\Must\Csv for One Industry ALL VIEW.csv", FileFormat:=xlCSV, Local:=True
        .SaveAs Filename:="E:\users\Must Definition Dashboard\Convergence\Csv for One Industry ALL VIEW.csv", FileFormat:=xlCSV, Local:=True
        .Close False
    
    End With
    Application.DisplayAlerts = True
    
End Sub

And here is the screenshot:

enter image description here

0 Answers
Related