>Thankx for the help. The best thing for me is to use the GoTo() method, but how does this method works ? I tried using the following code:
>
>oWord = CreateObject("Word.Application")
>oDocument = oWord.Documents.Open("c:\...\sjabl.doc")
>oDocument.Goto(2)
>
>but the text is added at the end of the third page. What am I doing wrong ??
Unlike VFP's GOTO command with a single parameter, Word's a little more flexible, as it has lots of things to GoTo(). According to Word's VBA Help file, the syntax is:
expression.GoTo(nWhat, nWhich, nCount, nName)Most of these parameters use constants.
nWhat represents what you want to move to, a few of which are: wdGoToGraphic (8), wdGoToTable (2), wdGotoSpellingError (13), or wdGoToPage (1).
nWhich give the direction to go, some of which are: wdGoToNext (2), wdGoToFirst (1), wdGoToAbsolute (1), wdGoToLast(-1). wdGoToFirst and wdGoToAbsolute are the same value -- either you're going to the first item (and don't pass
nCount or your going to the 3rd item -- use the constant name that best documents what you want to do.
nCount is simply a number to tell how many of
nWhats to move in
nWhich direction.
nName is used only if your
nWhat references a field, object, bookmark or comment, each of which can be referenced by name.
So, to get to the second page, you'd use:
#DEFINE wdGoToPage 1
#DEFINE wdGoToAbsolute 1
oDocument.Goto(wdGoToPage, wdGoToAbsolute, 2)
and that should get you there.
- della