To anyone interested:

var bm: OLEVariant;

bm:= 1; WD1.Bookmarks.Item(bm).Select;  where bm is a ref to the Bookmarks 
index (initial 1)

Should have seen it yesterday if I'd looked further than the end of my nose!

Regards

Steve



-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
Behalf Of Wilson, Stephen
Sent: 17 December 2007 12:03
To: [email protected]
Subject: [delphi-en] Word Automation


Hi all

I'm using Delphi 5 OLEServer TWordApplication and TWordDocument as follows:

WA1.Connect;
WA1.Visible := True;
Filename:= 'C:\HPB.dot';

WA1.Documents.Open(Filename,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
WD1.ConnectTo(WA1.ActiveDocument);
if WD1.Bookmarks.Exists('Diag') then
 begin
  st:= 19; nd:= 30;
  WD1.Range(st,nd).Select;
  WA1.Selection.TypeText('Test text');
 end;

What I want to do is select the bookmarked text (bookmark id ='Diag'.  In the 
above example I have selected it by hardcoding the start and end of the range, 
but how can I do it by simply referring to the existing bookmark? I checked out 
MSDN and found 

ActiveDocument.Bookmarks("temp").Select 

at http://msdn2.microsoft.com/en-us/library/aa192170(office.10).aspx , but 
WA1.ActiveDocument.Bookmarks('Diag').Select (or WD1.Bookmarks('Diag').Select) 
does not work.  

Thanks in advance for any help . . .

Best wishes

Steve


***************************************************************************
This e-mail and any files transmitted with it are confidential. If you are not 
the intended recipient, any reading, printing, storage, disclosure, copying or 
any other action taken in respect of this e-mail is prohibited and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately by using the reply function and then permanently delete what you 
have received.
Content of emails received by this Trust will be subject to disclosure under 
the Freedom of Information Act 2000, subject to the specified exemptions, 
including the Data Protection Act 1998 and Caldicott Guardian principles.
This footnote also confirms that, unless otherwise stated, this email message 
has been swept by Sophos Anti-virus for the presence of computer viruses.
***************************************************************************



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links





***************************************************************************
This e-mail and any files transmitted with it are confidential. If you are not 
the intended recipient, any reading, printing, storage, disclosure, copying or 
any other action taken in respect of this e-mail is prohibited and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately by using the reply function and then permanently delete what you 
have received.
Content of emails received by this Trust will be subject to disclosure under 
the Freedom of Information Act 2000, subject to the specified exemptions, 
including the Data Protection Act 1998 and Caldicott Guardian principles.
This footnote also confirms that, unless otherwise stated, this email message 
has been swept by Sophos Anti-virus for the presence of computer viruses.
***************************************************************************

Reply via email to