Check for Open Application

Hello,

I am trying to write a simple script and all I need to do is check if
there is all ready a running instance of the word application. I look
and couldn't find much on google how to do this...which probably means
it's really easy, so I'm sorry for this post but I'm still learning :slight_smile:

Thanks in advance for your help!

koooee

ยทยทยท

--
Posted via http://www.ruby-forum.com/.

Tobias Weber wrote:

In article <9e5b09fa795c251950ba3bc19dc04d34@ruby-forum.com>,

there is all ready a running instance of the word application. I look

Microsoft Word?

Yes Microsfot Word

and couldn't find much on google how to do this...which probably means

Which OS?
On the Mac you can use Apple Events or NSWorkspace through various
bridges.

Windows Vista is the OS.

Thanks for the interest!

koooee

ยทยทยท

Not Thisguy <nickkolegraf@hotmail.com> wrote:

--
Posted via http://www.ruby-forum.com/\.

Not Thisguy wrote:

Hello,

I am trying to write a simple script and all I need to do is check if
there is all ready a running instance of the word application. I look
and couldn't find much on google how to do this...which probably means
it's really easy, so I'm sorry for this post but I'm still learning :slight_smile:

Thanks in advance for your help!

koooee

One option is to try to connect to a running instance of Word. If there
is no running instance of Word, a WIN32OLERuntimeError exception will be
raised. So you could do the following:

require 'win32ole'

begin
    word = WIN32OLE.connect('Word.Application')
rescue WIN32OLERuntimeError
    word = WIN32OLE.new('Word.Application')
    word.Visible = true
end

David

ยทยทยท

--
Posted via http://www.ruby-forum.com/\.

David Mullet wrote:

One option is to try to connect to a running instance of Word. If there
is no running instance of Word, a WIN32OLERuntimeError exception will be
raised. So you could do the following:

require 'win32ole'

begin
    word = WIN32OLE.connect('Word.Application')
rescue WIN32OLERuntimeError
    word = WIN32OLE.new('Word.Application')
    word.Visible = true
end

David

http://rubyonwindows.blogspot.com
Ruby on Windows: word

Awsome thank you so much!!

ยทยทยท

--
Posted via http://www.ruby-forum.com/\.