Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting text from a Module into an endnote

0 views
Skip to first unread message

Peter Morris

unread,
Feb 22, 2002, 12:27:27 PM2/22/02
to
I want to use the Insert Endnote command then run a macro to collect the
relevant text to be inserted (the I bar will be in the endnote at this time)
and insert it in the endnote.

So far I can run the macro and collect the data, but when I use the command:

ActiveDocument.Range.InsertAfter (Ref2$)

where Ref2$ contains the information. This is inserted into the body of the
document at the point at which the endnot number is place - note in the
endnote itself?

Any advice gratefully received.

Peter


Dave Lett

unread,
Feb 22, 2002, 2:49:05 PM2/22/02
to
Hi Peter,

You can try
ActiveDocument.StoryRanges(wdEndnotesStory).InsertAfter "Test"

This will _not_ add a new endnote to your document. It will simply add that
text to the end of the last endnote.

If you want to add a new endnote, you don't need to have the I bar (better
to call it the "insertion point") in the endnotes area. Instead, have the
insertion point in the place you want to insert the footnote and use
something like the following:
ActiveDocument.Endnotes.Add Range:=Selection.Range, Text:="Add an endnote."

HTH
"Peter Morris" <pjmo...@iee.org> wrote in message
news:a55v1v$145$1...@newsg2.svr.pol.co.uk...

Peter Morris

unread,
Feb 22, 2002, 6:52:42 PM2/22/02
to
Dave,

Many thanks for your advice which has worked well.

However, I also need to format a section of the text in italics while the
remainder is in normal font. I have tried a number of approaches (having
used your advice) but none seem to work. This seems to be for a number of
reasons. I am now trying the section of code below, but this fails because
it says the endnote referred to doesn't exist. But even if it did work this
is only good when I know which endnote I have just entered and I have not
identified any mechanism for finding that out? I can't believe that it is
as difficult as I seem to be making it. So in addition to any advice you can
give on this specific point can you recommend a good book on programming
word?

ActiveDocument.Endnotes.Add Range:=Selection.Range, Text:=Ref2$

With Selection.Endnotes(1)
.Range.Start = cStart
.Range.End = cEnd
.Range.Italic = True
End With

Ref2$ is the data to be inserted into the endnote. cStart is the character
position at which I want the Italics to start and cEnd is the last character
to be italicised.

Any ideas gratefully received. Many thanks

Peter

"Dave Lett" <dl...@menusoft.com> wrote in message
news:#xIMQj9uBHA.1608@tkmsftngp04...

Dave Lett

unread,
Feb 25, 2002, 8:41:29 AM2/25/02
to
Hi Peter,

Your routine doesn't work because you are using Selection.Endnotes(1) and
Word doesn't recognize that you have an endnote in the selection. The
following routine should clear that up for you. Notice that the routine sets
a range object (where you were using Selection.Endnotes(1)) and then extends
the ending point of that range to include the endnote.

Dim oRngItalic As Range
Dim oRngEndnote As Range
Set oRngEndnote = Selection.Range
ActiveDocument.Endnotes.Add Range:=oRngEndnote, Text:=Ref2$
With oRngEndnote
.End = .End + 1
With .Endnotes(1)
Set oRngItalic = oRngEndnote.Endnotes(1).Range
With oRngItalic
.Start = cStart
.End = cEnd
.Font.Italic = True
End With
End With
End With

HTH
"Peter Morris" <pjmo...@iee.org> wrote in message

news:a56lka$m1n$1...@newsg3.svr.pol.co.uk...

0 new messages