From: Gilbert Rebhan Date: 2008-02-22T04:44:59+09:00 Subject: Re: win32ole, how to detect docfile is already opened ? > 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