Board index » delphi » Word Automation - Find out if file with file name is open

Word Automation - Find out if file with file name is open

Hi,
I am trying to find out if a file with a specific filename is already open
in word.

Something like (wrong Delpi code, but as an example):
WordApplication1.ActiveDocument.Fullname=Specifik name

1. This code works if there is only one document open in word already, but
does not work if word opens without any documents open.
2. If there are several documents open I cannot find out if the document is
open amongst all 10 documents

How can I resolve the two issues above (code if possible)?

Thanks!
/Per

 

Re:Word Automation - Find out if file with file name is open


Hi,
I am trying to find out if a file with a specific filename is already open
in word.

Something like (wrong Delpi code, but as an example):
WordApplication1.ActiveDocument.Fullname=Specifik name

1. This code works if there is only one document open in word already, but
does not work if word opens without any documents open.
2. If there are several documents open I cannot find out if the document is
open amongst all 10 documents

How can I resolve the two issues above (code if possible)?

Thanks!
/Per

Re:Word Automation - Find out if file with file name is open


Quote
> Something like (wrong Delpi code, but as an example):
> WordApplication1.ActiveDocument.Fullname=Specifik name

Something like:

   DocNo:=0;
    for i:=1 to WordApplication1.Documents.Count do begin
        if WordApplication1.Documents.Fullname=Specific.Name then begin
            DocNo:=i;
            break;
        end;
    end;

Oliver Townshend

Other Threads