I am trying to call a COM object which expects a variant datatype to
be passed in to the COM API object. However, I get "<COMObject
<unknown>>" and the program fails.
Below is my code in Python, and the same code in VB which is working
fine...
I guess this is a variant problem with python? How can I make this
work? Would appreciate if someone can guide me as I am a python
newbie... :-)
Thanks very much...
##In Python
def setAddOnValue(oBusObj
oAddOns = oBusObj.AddOns
print oAddOns #returns "<COMObject <unknown>>"
print oAddOns.Count #return 3
for x in range(1, oAddOns.Count):
oAddOn = oAddOns.Item(x) #expects variant datatype for the x
variable
##In VB
Public Function setAddOnValue(oBusObj As Variant, strAddOnLabel As
String, strPropLabel As String, oVal As Variant) As Boolean
Dim x, y
Dim oAddOns As CAddOns
Dim oAddOn As CAddOn
Dim oAddOnValues As CAddOnValues
Dim oAddOnValue As CAddOnValue
setAddOnValue = False
Set oAddOns = oBusObj.AddOns
For x = 1 To oAddOns.Count
Set oAddOn = oAddOns.Item(x)
If oAddOn.AddOnName = strAddOnLabel Then
Set oAddOnValues = oAddOn.AddOnValues
For y = 1 To oAddOnValues.Count
Set oAddOnValue = oAddOnValues.Item(y)
If oAddOnValue.PropertyLabel = strPropLabel Then
setAddOnValue = True
Set oAddOnValue.Data = oVal
Exit For
End If
Next y
End If
If setAddOnValue = True Then
Exit For
End If
Next x
End Function 3 2981
Try running makepy on the typelib that contains the objects.
Also, the actual error msg that if fails with would be helpful.
Roger
"Annie" <ai******@yahoo.com> wrote in message
news:b9**************************@posting.google.c om... I am trying to call a COM object which expects a variant datatype to be passed in to the COM API object. However, I get "<COMObject <unknown>>" and the program fails.
Below is my code in Python, and the same code in VB which is working fine...
I guess this is a variant problem with python? How can I make this work? Would appreciate if someone can guide me as I am a python newbie... :-)
Thanks very much...
##In Python def setAddOnValue(oBusObj oAddOns = oBusObj.AddOns print oAddOns #returns "<COMObject <unknown>>" print oAddOns.Count #return 3 for x in range(1, oAddOns.Count): oAddOn = oAddOns.Item(x) #expects variant datatype for the x variable ##In VB Public Function setAddOnValue(oBusObj As Variant, strAddOnLabel As String, strPropLabel As String, oVal As Variant) As Boolean Dim x, y Dim oAddOns As CAddOns Dim oAddOn As CAddOn Dim oAddOnValues As CAddOnValues Dim oAddOnValue As CAddOnValue
setAddOnValue = False Set oAddOns = oBusObj.AddOns
For x = 1 To oAddOns.Count Set oAddOn = oAddOns.Item(x) If oAddOn.AddOnName = strAddOnLabel Then Set oAddOnValues = oAddOn.AddOnValues For y = 1 To oAddOnValues.Count Set oAddOnValue = oAddOnValues.Item(y) If oAddOnValue.PropertyLabel = strPropLabel Then setAddOnValue = True Set oAddOnValue.Data = oVal Exit For End If Next y End If If setAddOnValue = True Then Exit For End If Next x End Function
hi Roger,
10s for replying..
i do running the makepy on that typelib. but can u pls teach me on
how to include to my Python program??
10s in advance
"Roger Upole" <ru****@hotmail.com> wrote in message news:<40********@127.0.0.1>... Try running makepy on the typelib that contains the objects. Also, the actual error msg that if fails with would be helpful. Roger
"Annie" <ai******@yahoo.com> wrote in message news:b9**************************@posting.google.c om... I am trying to call a COM object which expects a variant datatype to be passed in to the COM API object. However, I get "<COMObject <unknown>>" and the program fails.
Below is my code in Python, and the same code in VB which is working fine...
I guess this is a variant problem with python? How can I make this work? Would appreciate if someone can guide me as I am a python newbie... :-)
Thanks very much...
##In Python def setAddOnValue(oBusObj oAddOns = oBusObj.AddOns print oAddOns #returns "<COMObject <unknown>>" print oAddOns.Count #return 3 for x in range(1, oAddOns.Count): oAddOn = oAddOns.Item(x) #expects variant datatype for the x variable ##In VB Public Function setAddOnValue(oBusObj As Variant, strAddOnLabel As String, strPropLabel As String, oVal As Variant) As Boolean Dim x, y Dim oAddOns As CAddOns Dim oAddOn As CAddOn Dim oAddOnValues As CAddOnValues Dim oAddOnValue As CAddOnValue
setAddOnValue = False Set oAddOns = oBusObj.AddOns
For x = 1 To oAddOns.Count Set oAddOn = oAddOns.Item(x) If oAddOn.AddOnName = strAddOnLabel Then Set oAddOnValues = oAddOn.AddOnValues For y = 1 To oAddOnValues.Count Set oAddOnValue = oAddOnValues.Item(y) If oAddOnValue.PropertyLabel = strPropLabel Then setAddOnValue = True Set oAddOnValue.Data = oVal Exit For End If Next y End If If setAddOnValue = True Then Exit For End If Next x End Function
Normally if you've run makepy, the support should be invoked automatically
when you create an instance. What do you get back when you use
win32com.client.gencache.EnsureDispatch ?
Roger
"Annie" <ai******@yahoo.com> wrote in message
news:b9**************************@posting.google.c om... hi Roger, 10s for replying.. i do running the makepy on that typelib. but can u pls teach me on how to include to my Python program?? 10s in advance
"Roger Upole" <ru****@hotmail.com> wrote in message
news:<40********@127.0.0.1>... Try running makepy on the typelib that contains the objects. Also, the actual error msg that if fails with would be helpful. Roger
"Annie" <ai******@yahoo.com> wrote in message news:b9**************************@posting.google.c om... I am trying to call a COM object which expects a variant datatype to be passed in to the COM API object. However, I get "<COMObject <unknown>>" and the program fails.
Below is my code in Python, and the same code in VB which is working fine...
I guess this is a variant problem with python? How can I make this work? Would appreciate if someone can guide me as I am a python newbie... :-)
Thanks very much...
##In Python def setAddOnValue(oBusObj oAddOns = oBusObj.AddOns print oAddOns #returns "<COMObject <unknown>>" print oAddOns.Count #return 3 for x in range(1, oAddOns.Count): oAddOn = oAddOns.Item(x) #expects variant datatype for the x variable ##In VB Public Function setAddOnValue(oBusObj As Variant, strAddOnLabel As String, strPropLabel As String, oVal As Variant) As Boolean Dim x, y Dim oAddOns As CAddOns Dim oAddOn As CAddOn Dim oAddOnValues As CAddOnValues Dim oAddOnValue As CAddOnValue
setAddOnValue = False Set oAddOns = oBusObj.AddOns
For x = 1 To oAddOns.Count Set oAddOn = oAddOns.Item(x) If oAddOn.AddOnName = strAddOnLabel Then Set oAddOnValues = oAddOn.AddOnValues For y = 1 To oAddOnValues.Count Set oAddOnValue = oAddOnValues.Item(y) If oAddOnValue.PropertyLabel = strPropLabel Then setAddOnValue = True Set oAddOnValue.Data = oVal Exit For End If Next y End If If setAddOnValue = True Then Exit For End If Next x End Function This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt Smith |
last post by:
Hi, all.
Just a quick question, when setting a COM process to read a value from
a pre-defined register index, I think, I have to change the variable
that the value will be returned to (as I have...
|
by: Steve Knight |
last post by:
Hello,
I'm new to Boost & Python and I'm diving straight in by trying to
write an extension module to a third party library. Foolishness
probably, but I don't have much choice!
My question...
|
by: JD |
last post by:
This is more details about my problem, which I already managed
to post as a Python bug to Sourceforge
This problem is not related to the bug I encountered earlier, and
this is related to a...
|
by: David MacQuigg |
last post by:
I am starting a new thread so we can avoid some of the non-productive
argument following my earlier post "What is good about Prothon". At
Mr. Hahn's request, I will avoid using the name "Prothon"...
|
by: Andrew Ayre |
last post by:
Hi, I can't seem to get the library built, and any help is greatly
appreciated. Here is the info:
Windows XP
Borland C++ Builder 5
Latest Boost source code (downloaded at the weekend)
Windows...
|
by: Gigs_ |
last post by:
Is there any way to convert ocaml code to python? but not manually
thx
|
by: Mark Dufour |
last post by:
Hi all,
I have recently released version 0.0.20 and 0.0.21 of Shed Skin, an
optimizing Python-to-C++ compiler. Shed Skin allows for translation of
pure (unmodified), implicitly statically typed...
|
by: vml |
last post by:
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
class Fop:
_public_methods_ =
def SqVal(self,*val):
#vol=(val,val)...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |