COM :: VARIANT -eek

Discussion in 'Python' started by Matt Smith, Aug 11, 2003.

  1. Matt Smith

    Matt Smith Guest

    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
     
    Matt Smith, Aug 11, 2003
    #1
    1. Advertising

  2. Matt Smith

    Mark Hammond Guest

    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.
     
    Mark Hammond, Aug 12, 2003
    #2
    1. Advertising

  3. Matt Smith

    Matt Smith Guest

    Mark Hammond <> wrote in message news:<bha8cu$2q3l$>...
    > 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 ?
     
    Matt Smith, Aug 13, 2003
    #3
  4. Matt Smith

    Mark Hammond Guest

    Matt Smith wrote:
    > Mark Hammond <> wrote in message news:<bha8cu$2q3l$>...


    > 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
     
    Mark Hammond, Aug 14, 2003
    #4
  5. Matt Smith

    Matt Smith Guest

    Mark Hammond <> wrote in message news:<bhefuk$2gvi$>...
    > Matt Smith wrote:
    > > Mark Hammond <> wrote in message news:<bha8cu$2q3l$>...

    >
    > > 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.
     
    Matt Smith, Aug 14, 2003
    #5
  6. Matt Smith

    Matt Smith Guest

    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
     
    Matt Smith, Aug 14, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Sparrow

    UDF Parameters always Variant - help!!

    John Sparrow, Jul 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    458
    John Sparrow
    Jul 29, 2003
  2. Guest

    variant

    Guest, Dec 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    2,245
    John Timney \(Microsoft MVP\)
    Dec 17, 2003
  3. the idiot

    eek firefox prob with divs

    the idiot, Feb 23, 2005, in forum: HTML
    Replies:
    14
    Views:
    830
    the idiot
    Feb 24, 2005
  4. the idiot

    eek where my scrollybar

    the idiot, Feb 28, 2005, in forum: HTML
    Replies:
    11
    Views:
    696
    Beauregard T. Shagnasty
    Mar 1, 2005
  5. the idiot

    eek strange thig happening

    the idiot, Sep 28, 2005, in forum: HTML
    Replies:
    4
    Views:
    378
    the idiot
    Sep 28, 2005
Loading...

Share This Page