Problem mapping VB com code to Python

max max at theslimmers.net
Sun Dec 21 13:48:23 EST 2003


No luck, I have tried all possible case combinations and permutations
of what I see in the com brouser.  The only place I have found
references to the com module qbFC2_1Lib is in the "Registered Type
Libraries".

Is there another way to access the com module then client.Dispatch()?

What is the mapping of the VB statememnt  
" Dim sessionManager As New QBFC2_1Lib.QBSessionManager"
does this imply something other than late binding.   

When I ran makepy it generated a file containing lots of information
about the module, I don't know how to figure out what it means.

How is the output of makepy used, can it tell me something about how
to connect to the corresponding COM module>

I am really at a loss here, I don't understand enough about COM or VB
to figure this out.

max



 

"Ahmed MOHAMED ALI" <ahmedmo at wanadoo.fr> wrote in message news:<bs230r$geq$1 at news-reader1.wanadoo.fr>...
> Hello,
> 
> try this
> 
> obj = win32com.client.Dispatch("QBFC2_1.QBSessionManager")
> 
> Ahmed
> 
> "max" <max at theslimmers.net> wrote in message
> news:4f55e45a.0312191451.73b8f84b at posting.google.com...
> > 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.QBSessionManager"
> > into a corresponding Python statement, when I try
> > obj = win32com.Client.Dispatch("QBFC2_1Lib.QBSessionManager") 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
> >
> >
> >
> > =======Traceback =============
> > >>> o = win32com.client.Dispatch("QBFC2_1Lib.QBSessionManager")
> > Traceback (most recent call last):
> >   File "<interactive input>", line 1, in ?
> >   File "C:\Python23\lib\site-packages\win32com\client\__init__.py",
> > line 95, in Dispatch
> >     dispatch, userName =
> > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
> >   File "C:\Python23\lib\site-packages\win32com\client\dynamic.py",
> > line 84, in _GetGoodDispatchAndUserName
> >     return (_GetGoodDispatch(IDispatch, clsctx), userName)
> >   File "C:\Python23\lib\site-packages\win32com\client\dynamic.py",
> > line 72, in _GetGoodDispatch
> >     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> > pythoncom.IID_IDispatch)
> > 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.QBSessionManager
> >     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.IMsgSetRequest
> >     'Create a qbXML version 2.1 message
> >     Set requestSet = sessionManager.CreateMsgSetRequest(2, 1)
> >
> >     'Add a request to the request set.
> >     Dim customerAdd As QBFC2_1Lib.ICustomerAdd
> >     'AppendCustomerAddRq is called only once here, even though two
> > values are being set.
> >     Set customerAdd = requestSet.AppendCustomerAddRq
> >     customerAdd.Name.SetValue "Joe"
> >     customerAdd.CustomerTypeRef.FullName.SetValue "East Coast"
> >
> >     'Indicate that all requests should be processed, even if one has
> > an error
> >     requestSet.Attributes.OnError = roeContinue
> >
> >
> >     'Send the request set to QuickBooks
> >
> >     Dim responseSet As QBFC2_1Lib.IMsgSetResponse
> >     Set responseSet = sessionManager.DoRequests(requestSet)




More information about the Python-list mailing list