I am trying to use a sdk to access quickbooks, the sdk provided a COM
interface and I think it installed the com server files/dlls. A VB
code example is provided, but I can't figure out how to map "Dim
sessionManager As New QBFC2_1Lib.QBSe ssionManager"
into a corresponding Python statement, when I try
obj = win32com.Client .Dispatch("QBFC 2_1Lib.QBSessio nManager") I get
traceback Shown below.
I have been able to run makepy and it generates a lovely file. I can
find a Type Library, but need a little help mapping this to be able to
access the com object and call its methods.
I have included a snipit of the sample VB code and the traceback from
my attempt to create a client com object ?
Any help much appreciated,
max
=======Tracebac k =============[color=blue][color=green][color=darkred]
>>> o = win32com.client .Dispatch("QBFC 2_1Lib.QBSessio nManager")[/color][/color][/color]
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python23\li b\site-packages\win32c om\client\__ini t__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoo dDispatchAndUse rName(dispatch, userName,clsctx )
File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py",
line 84, in _GetGoodDispatc hAndUserName
return (_GetGoodDispat ch(IDispatch, clsctx), userName)
File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py",
line 72, in _GetGoodDispatc h
IDispatch = pythoncom.CoCre ateInstance(IDi spatch, None, clsctx,
pythoncom.IID_I Dispatch)
com_error: (-2147221005, 'Invalid class string', None, None)
========= Sample VB code ==========
Option Explicit
Public Sub Main()
On Error GoTo ErrHandler
'Establish a communication channel with QuickBooks
'Create the session manager object, and initiate a conversation
with QuickBooks
Dim sessionManager As New QBFC2_1Lib.QBSe ssionManager
sessionManager. OpenConnection " ", "QBFC Developer's Guide"
sessionManager. BeginSession "", omDontCare
'Build a set of requests - in this case, containing only one
request
'Create the request set (the message set request object)
Dim requestSet As QBFC2_1Lib.IMsg SetRequest
'Create a qbXML version 2.1 message
Set requestSet = sessionManager. CreateMsgSetReq uest(2, 1)
'Add a request to the request set.
Dim customerAdd As QBFC2_1Lib.ICus tomerAdd
'AppendCustomer AddRq is called only once here, even though two
values are being set.
Set customerAdd = requestSet.Appe ndCustomerAddRq
customerAdd.Nam e.SetValue "Joe"
customerAdd.Cus tomerTypeRef.Fu llName.SetValue "East Coast"
'Indicate that all requests should be processed, even if one has
an error
requestSet.Attr ibutes.OnError = roeContinue
'Send the request set to QuickBooks
Dim responseSet As QBFC2_1Lib.IMsg SetResponse
Set responseSet = sessionManager. DoRequests(requ estSet)
interface and I think it installed the com server files/dlls. A VB
code example is provided, but I can't figure out how to map "Dim
sessionManager As New QBFC2_1Lib.QBSe ssionManager"
into a corresponding Python statement, when I try
obj = win32com.Client .Dispatch("QBFC 2_1Lib.QBSessio nManager") I get
traceback Shown below.
I have been able to run makepy and it generates a lovely file. I can
find a Type Library, but need a little help mapping this to be able to
access the com object and call its methods.
I have included a snipit of the sample VB code and the traceback from
my attempt to create a client com object ?
Any help much appreciated,
max
=======Tracebac k =============[color=blue][color=green][color=darkred]
>>> o = win32com.client .Dispatch("QBFC 2_1Lib.QBSessio nManager")[/color][/color][/color]
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python23\li b\site-packages\win32c om\client\__ini t__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoo dDispatchAndUse rName(dispatch, userName,clsctx )
File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py",
line 84, in _GetGoodDispatc hAndUserName
return (_GetGoodDispat ch(IDispatch, clsctx), userName)
File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py",
line 72, in _GetGoodDispatc h
IDispatch = pythoncom.CoCre ateInstance(IDi spatch, None, clsctx,
pythoncom.IID_I Dispatch)
com_error: (-2147221005, 'Invalid class string', None, None)
========= Sample VB code ==========
Option Explicit
Public Sub Main()
On Error GoTo ErrHandler
'Establish a communication channel with QuickBooks
'Create the session manager object, and initiate a conversation
with QuickBooks
Dim sessionManager As New QBFC2_1Lib.QBSe ssionManager
sessionManager. OpenConnection " ", "QBFC Developer's Guide"
sessionManager. BeginSession "", omDontCare
'Build a set of requests - in this case, containing only one
request
'Create the request set (the message set request object)
Dim requestSet As QBFC2_1Lib.IMsg SetRequest
'Create a qbXML version 2.1 message
Set requestSet = sessionManager. CreateMsgSetReq uest(2, 1)
'Add a request to the request set.
Dim customerAdd As QBFC2_1Lib.ICus tomerAdd
'AppendCustomer AddRq is called only once here, even though two
values are being set.
Set customerAdd = requestSet.Appe ndCustomerAddRq
customerAdd.Nam e.SetValue "Joe"
customerAdd.Cus tomerTypeRef.Fu llName.SetValue "East Coast"
'Indicate that all requests should be processed, even if one has
an error
requestSet.Attr ibutes.OnError = roeContinue
'Send the request set to QuickBooks
Dim responseSet As QBFC2_1Lib.IMsg SetResponse
Set responseSet = sessionManager. DoRequests(requ estSet)
Comment