win32ole, how to detect docfile is already opened ?

G

Gilbert Rebhan

Hi,

running ruby 1.8.4 on Win2000, some word scripting
with Office 2003

require 'win32ole'

word = WIN32OLE.new('Word.Application')
doc = word.Documents.Open('c:/foobar.doc')

Question =

i want to do a text search and replace
and i need to detect whether the docfile
is already opened by someone else, when
word comes up with a dialog (3 radiobuttons)
similar to that =

Title = bla.doc already in use
|o| Open write protected readoonly
|o| Open a copy and merge afterwards
|o| Tell me when bla.doc is open

I want to check whether the docfile is
already opened, and if yes, i start
to loop until the docfile is free, then
do the replace ...

How do i realize whether the docfile is already opened ??

I searched already in irb via

puts docs.ole_methods.sort
and
puts docs.ole_methods.sort

but didn't come up with a solution

Any hints ?

Regards, Gilbert
 
G

Gilbert Rebhan

running ruby 1.8.4 on Win2000, some word scripting
with Office 2003

require 'win32ole'

word = WIN32OLE.new('Word.Application')
doc = word.Documents.Open('c:/foobar.doc')

Question =

i want to do a text search and replace
and i need to detect whether the docfile
is already opened by someone else, when
word comes up with a dialog (3 radiobuttons)
similar to that =

Title = bla.doc already in use
|o| Open write protected readoonly
|o| Open a copy and merge afterwards
|o| Tell me when bla.doc is open

I want to check whether the docfile is
already opened, and if yes, i start
to loop until the docfile is free, then
do the replace ...

OK, solved it 'lowlevel' with

File.exists?('~$foobar.doc')

means, if the file is already opened, there is
a corresponding file with leading ~$ before
the orginal filename, i.e. ~$foobar.doc


Regards, Gilbert
 

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
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top