Best Method for Logging Into QuickBooks Desktop on Locked Machine

Viewed 23

I am working on an automation project that involves opening an application, in this case QuickBooks Desktop, and entering in some information to login. The problem I am running into is that I cannot do this when the computer is locked (Windows Key + L), or put to sleep. I was wondering if anyone had any advice/solutions for trying to get this resolved. Below is my current code. It uses VBA to open the file, and a VBScript file with Task Scheduler to open the file at specific times. Any help is much appreciated.

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:

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
0 Answers
Related