I am very new to automation and am working on a project that involves entering into a QuickBooks file overnight and refreshing the 'Bank Feeds Center'. This is not supported by the QuickBooks API, so I believe the only way to do this is indirectly. To do this, I am currently using VBA, with a VBScript file to run the code. The VBA code below opens QuickBooks, enters the Password, and then sends 'Enter' to open the file. My only problem is, this code only works when I am logged into my machine. I was wondering if there is a way to modify this code so that it works when I lock the screen (windows key + L). The end goal for this project is to run this overnight and I cannot leave my computer unlocked overnight. I am open to any alternative languages/solutions to this issue as well, as well as any potential advice.
VBA Code:
Public Sub openQB()
Dim qbPathStr As String
qbPathStr = "QuickBooks File Location"
Dim Shex As Object
Set Shex = CreateObject("Shell.Application")
On Error Resume Next
Shex.Open (qbPathStr)
Application.Wait Now + #12:00:30 AM#
AppActivate "QuickBooks Desktop Pro 2021"
SendKeys ("Password")
SendKeys ("~")
End Sub
VBScript Code (Using Task Scheduler to run at specific times):
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.Workbooks.Open("Excel file with VBA code")
objExcel.run "openQB"
objExcel.Quit
Set objExcel = Nothing
Set objWorkbook = Nothing
wcript.quit