467,222 Members | 1,459 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,222 developers. It's quick & easy.

COM :: VARIANT -eek

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 to do for the same
function in perl), into a VARIANT, However when i run the variant
code....

'serialIndex = win32com.client.pythoncom.VT_VARIANT'

no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
still returns a type mismatch error. I may be doing something wrong or
getting confused with variant processes in python. I do know the code
I use in perl to do this works but I dont know how to translate this,
fully, into python.

perl code for variant =
Win32::OLE::Variant::Variant(Win32::OLE::Variant:: VT_VARIANT|Win32::OLE::VARIANT::VT_BYREF,
0)

Cheers in advance,
Matt
Jul 18 '05 #1
  • viewed: 3184
Share:
5 Replies
Matt Smith wrote:
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 to do for the same
function in perl), into a VARIANT, However when i run the variant
code....

'serialIndex = win32com.client.pythoncom.VT_VARIANT'

no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
still returns a type mismatch error. I may be doing something wrong or
getting confused with variant processes in python. I do know the code
I use in perl to do this works but I dont know how to translate this,
fully, into python.

perl code for variant =
Win32::OLE::Variant::Variant(Win32::OLE::Variant:: VT_VARIANT|Win32::OLE::VARIANT::VT_BYREF,
0)


Unfortunately, you really can't do this in a clean way. The best thing
to do is to ensure "makepy" has been run for your COM object, and the
right magic should always happen.

Mark.

Jul 18 '05 #2
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>...
Matt Smith wrote:
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 to do for the same
function in perl), into a VARIANT, However when i run the variant
code....

'serialIndex = win32com.client.pythoncom.VT_VARIANT'

no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
still returns a type mismatch error. I may be doing something wrong or
getting confused with variant processes in python. I do know the code
I use in perl to do this works but I dont know how to translate this,
fully, into python.

perl code for variant =
Win32::OLE::Variant::Variant(Win32::OLE::Variant:: VT_VARIANT|Win32::OLE::VARIANT::VT_BYREF,
0)


Unfortunately, you really can't do this in a clean way. The best thing
to do is to ensure "makepy" has been run for your COM object, and the
right magic should always happen.

Mark.


Hi, thanks for the reply,

My problem is now this, when i go to makepy tool in pythonwin, it does
not see/recognise the type library file I want it to convert. Is there
anyway to add the file to the list of .tlb files it does does?

Cheers,
Matt.

p.s. How do I include the generated makepy file into my code ?
Jul 18 '05 #3
Matt Smith wrote:
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>... My problem is now this, when i go to makepy tool in pythonwin, it does
not see/recognise the type library file I want it to convert. Is there
anyway to add the file to the list of .tlb files it does does?
These type libraries are in the registry. You may be able to pass the
filename on the commandline to makepy.
p.s. How do I include the generated makepy file into my code ?


In generaly, you just need to generate the file and do nothing else. At
runtime, Python will see these generated files and automatically use them.

I don't know how that will go with your type library though.

Mark

Jul 18 '05 #4
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>...
Matt Smith wrote:
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bh***********@arachne.labyrinth.net.au>...

My problem is now this, when i go to makepy tool in pythonwin, it does
not see/recognise the type library file I want it to convert. Is there
anyway to add the file to the list of .tlb files it does does?


These type libraries are in the registry. You may be able to pass the
filename on the commandline to makepy.
p.s. How do I include the generated makepy file into my code ?


In generaly, you just need to generate the file and do nothing else. At
runtime, Python will see these generated files and automatically use them.

I don't know how that will go with your type library though.

Mark


Hi again,

I had to register the .tlb file (as it didnt do it automatically at
installation [don't know why]) using a vb .tlb registration script,
which worked fine and now I have a lovily makepy.py generated file for
my .tlb file.

My problem is now this, When I try to run the file (in pythonwins
interactive window) using the code:

from win32com.client include gencache
gencache.EnsureModule('{AF684923-D245-11D3-8DE8-00A024ACAB85x0x1x0}',
0, 1, 0)

pythonwin returns the error:

ImportError: No module named
gen_py.AF684923-D245-11D3-8DE8-00A024ACAB85x0x1x0

I have tested it with other makepy.py generated files and they all
return the same error. Do I need to tell python where to find these
makepy files? or is there some other reason as to why it does not want
to use ANY makepy.py files

thanks for all the help,
matt.
Jul 18 '05 #5
hi again, sorry about all these updates but cant remember what I
posted in the last message and google ahsnt updated yet :/.

My current probelm is that I have generated a makepy file and then run
ensureModule on it to ensure early binding. However when I came to run
Dispatch it still ran with late binding :(. If i ran the script with
ensureDispatch would that help (instead of normal client.Dispatch that
is)

thanks again,
matt.

p.s. forgot to post the .tlb register website address here it is:

http://www.vbaccelerator.com/codelib/tlb/vbregtlb.htm
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Matt Smith | last post: by
1 post views Thread by C. N. Sridhar | last post: by
19 posts views Thread by Jon Davis | last post: by
reply views Thread by .::alex::. | last post: by
2 posts views Thread by Heike | last post: by
1 post views Thread by morten | last post: by
4 posts views Thread by jainchar | last post: by
reply views Thread by Adict | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.