Question

Bonjour, Hello,

I'm making this delphi application that I use to create word documents. I'm done with basic word operations (create/save, text, tables..etc).

What I need to do is to insert Page Numbers of headings as Cross Reference in the text. Something like :

"... and the process works as explained on page 23..."

where page number is a hyperlink to a heading. When I recorded a Macros in word it looks like:

    Selection.InsertCrossReference ReferenceType:="Heading", _
    ReferenceKind:=wdPageNumber, ReferenceItem:="49", InsertAsHyperlink:=True _
    , IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" "

What would be the equivalent in Delphi please?

Thanks in advance! Arjun.

Was it helpful?

Solution

Even when you're using Late Binding you still need to provide all of the parameters in the same order as the original declaration.

expression.InsertCrossReference(ReferenceType, ReferenceKind, ReferenceItem,
InsertAsHyperlink, IncludePosition, SeparateNumbers, SeparatorString)

If you aren't using a parameter then you can replace it with EmptyParam.

So I think your code will be:

Selection.InsertCrossReference('Heading', 7, '49', True, False, False, ' ');

(I think that wdPageNumber's value is 7).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top