Check for Open Application

N

Not Thisguy

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 :)

Thanks in advance for your help!


koooee
 
T

Tobias Weber

Not Thisguy said:
there is all ready a running instance of the word application. I look

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

David Mullet

Not said:
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 :)

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

http://rubyonwindows.blogspot.com
http://rubyonwindows.blogspot.com/search/label/word
 
N

Not Thisguy

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

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top