Board index » delphi » How to goto bookmark in D5

How to goto bookmark in D5

Can someone tell me hot to goto a bookmark in a document. I have guessed
using the code below, but it gives me 2 problems.
1) I get a warning  - 'Constant Expression violatessubrange bounds' and
2) the goto produces a runtime error

Word97 ways I have a What and Which paramter. I presumed What is what I want
to goto (i.e. a bookamrk) and which is 'which one'.

Have I mis-interpretted?

Thanks

Kerry

procedure TInsertField.BookMListDblClick(Sender: TObject);
var
  MyBookMark, myWhat: OLEVariant;
begin
   MyWhat := wdGoToBookmark;
   MyBookMark := BookMList.Items.Strings[BookMList.ItemIndex];
   if TempMan.WordDocument.Bookmarks.Exists(MyBookmark) then
      TempMan.WordDocument.GoTo_(myWhat,MyBookmark);

 

Re:How to goto bookmark in D5


<<Kerry Frater:
I presumed What is what I want to goto (i.e. a
bookamrk) and which is 'which one'.

Quote

Never presume with Word, it isn't that transparent;
always check the help file. The Which parameter
has to be a WdGoToDirection constant, usually
wdGoToFirst (or EmptyParam). The parameter you
need to specify is the last (of four), the Name
parameter:
TempMan.WordDocument.GoTo_(myWhat,
  EmptyParam, EmptyParam, MyBookmark);

The warning you mention doesn't really matter, and
I don't think you'll find it's this bit of code that causes
it anyway.

--
Deborah Pate

Re:How to goto bookmark in D5


Thanks again Deborah,

You don't happen to know the equivalent to Goto a bookmark and make its
contents a highlighted selection in Delphi (I have used the following
construct elsewhere and wondered how to re-write it in delphi.

ActiveDocument.Bookmarks("BOOKM1").Select

Kerry

Quote
"Deborah Pate" <d.p...@cableinet.co.not-this-bit.uk> wrote in message

news:38b527b5@dnews...
Quote
> <<Kerry Frater:
> I presumed What is what I want to goto (i.e. a
> bookamrk) and which is 'which one'.

> Never presume with Word, it isn't that transparent;
> always check the help file. The Which parameter
> has to be a WdGoToDirection constant, usually
> wdGoToFirst (or EmptyParam). The parameter you
> need to specify is the last (of four), the Name
> parameter:
> TempMan.WordDocument.GoTo_(myWhat,
>   EmptyParam, EmptyParam, MyBookmark);

> The warning you mention doesn't really matter, and
> I don't think you'll find it's this bit of code that causes
> it anyway.

> --
> Deborah Pate

Re:How to goto bookmark in D5


I have worked this one out. I was thing that I needed the got in the
document. I actually wanted a goto in the application (along with
selection).

This moves the current position to the bookmark and selects it.

   MyWhat := wdGoToBookmark;
   MyBookMark := BookMList.Items.Strings[BookMList.ItemIndex];
   if TempMan.WordDocument.Bookmarks.Exists(MyBookmark) then

TempMan.WordApplication.Selection.goto_(MyWhat,EmptyParam,EmptyParam,MyBookM
ark);

Does anyone know if there will be more extensive documentation, or examples,
from the Delphi people on using their current recommended Office integration
components. Trying to cross-reference to the vb*.hlp files , looking at
word97.pas etc, just to see what "might" work and then try is making it long
winded to find out if certain techniques are possible (well it is for me). I
was hoping to write efficiently!

Kerry

Quote
"Kerry Frater" <ke...@lawyersweb.net> wrote in message

news:893sqf$9rl1@bornews.borland.com...
Quote
> Thanks again Deborah,

> You don't happen to know the equivalent to Goto a bookmark and make its
> contents a highlighted selection in Delphi (I have used the following
> construct elsewhere and wondered how to re-write it in delphi.

> ActiveDocument.Bookmarks("BOOKM1").Select

> Kerry

> "Deborah Pate" <d.p...@cableinet.co.not-this-bit.uk> wrote in message
> news:38b527b5@dnews...
> > <<Kerry Frater:
> > I presumed What is what I want to goto (i.e. a
> > bookamrk) and which is 'which one'.

> > Never presume with Word, it isn't that transparent;
> > always check the help file. The Which parameter
> > has to be a WdGoToDirection constant, usually
> > wdGoToFirst (or EmptyParam). The parameter you
> > need to specify is the last (of four), the Name
> > parameter:
> > TempMan.WordDocument.GoTo_(myWhat,
> >   EmptyParam, EmptyParam, MyBookmark);

> > The warning you mention doesn't really matter, and
> > I don't think you'll find it's this bit of code that causes
> > it anyway.

> > --
> > Deborah Pate

Other Threads