win32ole outlook run macro

Discussion in 'Ruby' started by zak, Mar 28, 2011.

  1. zak

    zak Guest

    Hi,

    with ruby and win32ole it is possible to call a user-defined macro in
    excel:

    excel = WIN32OLE.new('Excel.Application')
    excel.run('macroname')

    how about outlook?

    outlook = WIN32OLE.new('Outlook.Application')
    outlook.run('macroname')

    is not working.

    Thanks!
     
    zak, Mar 28, 2011
    #1
    1. Advertisements

  2. zak

    David Mullet Guest

    zak wrote in post #989572:
    If your Outlook macro is in the ThisOutlookSession module, then try
    calling your macro as a method of the Outlook Application object:

    outlook = WIN32OLE.new('Outlook.Application')
    outlook.macroname()

    David

    http://rubyonwindows.blogspot.com
     
    David Mullet, Mar 29, 2011
    #2
    1. Advertisements

  3. zak

    Nick Klauer Guest

    [Note: parts of this message were removed to make it a legal post.]

    Following along these lines, is there any reference for the OLE API for
    Office products or OLE in general? I've always wanted to work with the
    win32ole gem, but I don't know where to look on MSDN to know how to even
    play with those APIs.


    -Nick Klauer
     
    Nick Klauer, Mar 29, 2011
    #3
  4. Try http://support.microsoft.com/kb/q222101/

    It hasn't been updated for Offices 2007 and 2010, but it's general
    enough to be helpful with those versions, too.

    --=20
    Phillip Gawlowski

    Though the folk I have met,
    (Ah, how soon!) they forget
    When I've moved on to some other place,
    There may be one or two,
    When I've played and passed through,
    Who'll remember my song or my face.
     
    Phillip Gawlowski, Mar 29, 2011
    #4
  5. zak

    David Mullet Guest

    Nick Klauer wrote in post #989800:
    You'll also find many articles on win32ole automation (Excel, Word,
    Outlook, etc.) here:

    http://rubyonwindows.blogspot.com

    David
     
    David Mullet, Mar 30, 2011
    #5
  6. zak

    u.gotzes Guest

    Mully's hint worked well...until I switch to Outlook 2010 or 2013. With ruby 1.9.3 I get a "NoMethodError: unknown property or method: `Hallo' HRESULT error code:0x80020006"

    My ruby-script calls Hallo:
    require 'win32ole'
    outlook=WIN32OLE.connect('Outlook.Application')
    outlook.Hallo

    ....and the Hallo-macro in Projekt1/Microsoft Outlook Objekte/ThisOutlookSession is implemented as:
    Sub Hallo()
    MsgBox "Hallo"
    End Sub

    As far as I know Macros are activated. Any ideas how to fix this?

    Thanks,

    Uwe
     
    u.gotzes, May 26, 2014
    #6
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.