win32ole outlook run macro

Z

zak

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!
 
D

David Mullet

zak wrote in post #989572:
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!

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
 
N

Nick Klauer

[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
 
P

Phillip Gawlowski

Following along these lines, is there any reference for the OLE API for
Office products or OLE in general? =A0I'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.

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.
 
D

David Mullet

Nick Klauer wrote in post #989800:
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

You'll also find many articles on win32ole automation (Excel, Word,
Outlook, etc.) here:

http://rubyonwindows.blogspot.com

David
 
U

u.gotzes

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!

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top