Quickbooks SDK iAddCheck using VBA. Add a check from Excel or Access

Someone reading my part 1 of ??? tutorial on Quickbooks – sorry.. read the notes. 😉  – was struggling to find how to add checks. I wrote them this morning about what to look for in the On Screen Reference OSR for the Quickbooks SDK.

iCheckAdd

Under the Onscreen Reference, there is a iCheckAdd message. It demonstrates how to add checks. You need to open the OSR with Firefox or Internet Explorer. It does not properly open with Chrome or Edge… actually, I’m not sure if it opens with Edge. But Firefox opens it for sure.

The OSR default path is:

file:///C:/Program%20Files%20(x86)/Intuit/IDN/Common/newOSR/index.html

Because I use Chrome by default, I wrote a batch file to open the OSR with Firefox.

LaunchOSR.bat


start "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "C:\Program Files (x86)\Intuit\IDN\Common\newOSR\index.html"
exit 0

Using CheckAdd in VBA

Here is some VBA that creates a check – assuming the Bank Account name and the chart of accounts is correctly. It is setup to write me a check for $100,000.00. I greatly appreciate this. 😉

I’m sure you’ll need to tweak it. I had it working for something I was doing with a client. There is no error checking and you should use the function to get the return message. The variables should be passed to the function as well. Blah blah blah.. you know the routine.

Let me know if you get this working.

Function QBAddCheck()
Dim strCustName As String, checkno As String
Dim curAmount As Currency, strStreet1 As String, strStreet2 As String, strCity As String, strState As String, strZip As String
Dim strMemo As String
Dim strBankAccountID As String, strBankAccount As String
Dim strAccountID As String, strAccount As String

strCustName = "Matthew Moran"
checkno = "99555"
curAmount = 100000.0
strStreet1 = "12245 Main St."
strMemo = "because he is a good guy"
strStreet2 = ""
strCity = "Oxnard"
strState = "CA"
strZip = "93012"
strBankAccount = "[enter your Quickbooks bank account name]"
strAccount = "[enter the chart of accounts name]"

Dim smgr As QBSessionManager
Set smgr = New QBSessionManager

smgr.OpenConnection "", "your appname"
smgr.BeginSession "", omDontCare
Dim qresp As IResponse
Dim rList As IResponseList
'Dim chklist as ICheckRetList
Dim rMsg As IMsgSetRequest
Dim rMsgr As IMsgSetResponse
Dim iChk As ICheckAdd

Set rMsg = smgr.CreateMsgSetRequest("US", 13, 0)

Set iChk = rMsg.AppendCheckAddRq()
iChk.AccountRef.FullName.SetValue (strBankAccount)
iChk.PayeeEntityRef.FullName.SetValue (strCustName)
iChk.Address.Addr1.SetValue (strStreet1)
iChk.Address.Addr2.SetValue (strStreet2)
iChk.Address.City.SetValue (strCity)
iChk.Address.State.SetValue (strState)
iChk.Address.PostalCode.SetValue (strZip)
iChk.Memo.SetValue (strMemo)
Dim iExp As IExpenseLineAdd
Set iExp = iChk.ExpenseLineAddList.Append()
iExp.Amount.SetValue (curAmount)
iExp.AccountRef.FullName.SetValue (strAccount)
iExp.Memo.SetValue (strMemo)

Set rMsgr = smgr.DoRequests(rMsg)
strResponse = rMsgr.ToXMLString()

QBAddCheck = strResponse
End Function
Posted in Consulting, Microsoft Access, Programming, Quickbooks SDK, Tips and Tools and tagged , , .

2 Comments

  1. Great code for writing a check. I changed it slightly to accommodate vb.net vs 2015.

    Thanks Matthew for the help.

    Dim strResponse As String ‘<—– Added to define
    rMsgr = smgr.DoRequests(rMsg) '<——— Changed for VB.NET
    smgr = New QBSessionManagerClass '<—– Changed for VB.NET
    rMsgr = smgr.DoRequests(rMsg) '<——— Changed for VB.NET

    If Not smgrManager Is Nothing Then '<——– Don't forget to close the QB session
    smgrManager.EndSession()
    smgrManager.CloseConnection()
    End If

    • Thanks Gerard. I appreciate the update. I’ve toyed with showing the same code as asp.net C# – but, as indicated in our emails, time does not permit at this time.

      Between what I have posted and your input I think most can get things going. Thanks again.

Leave a Reply

Your email address will not be published. Required fields are marked *