D
daswifty
Hi, I am trying to create a Word C# add-in that will find all of the endnotes
in a document, re-sort them so that the first one will be #1, and add a
hyperlink back to the section heading that the endnote reference resides in.
Most everything is working well except I can't do two things:
1) Add formatted text programmatically to the endnote text. Endnotes.Add
doesn't allow a range (just text) and when I try to update the endnote after
adding a temporary text string, the resulting endnote text is blank:
Range = aDoc.Range(ref textStart, ref textEnd);
aDoc.Endnotes[1].Range = findE;
2) Add the hyperlink back to the section heading. This is most likely due to
my issue with the formatted text, but I have tried to work around it by using
a Find and trying to find the Endnote Text, but that isn't working either.
Are we not able to find Endnote Text programmatically? I tried a VBA macro as
well and it didn't work. Here is my C# approach:
Range findEndnote = aDoc.Content;
findEndnote.Find.Forward = true;
object objTrue = true;
object objEndnoteStyle = "Endnote Text";
object objEndnoteFind = aDoc.Styles.get_Item(ref objEndnoteStyle);
findEndnote.Find.set_Style(ref objEndnoteFind);
findEndnote.Find.Text = "Section";
findEndnote.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref objTrue, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
in a document, re-sort them so that the first one will be #1, and add a
hyperlink back to the section heading that the endnote reference resides in.
Most everything is working well except I can't do two things:
1) Add formatted text programmatically to the endnote text. Endnotes.Add
doesn't allow a range (just text) and when I try to update the endnote after
adding a temporary text string, the resulting endnote text is blank:
Range = aDoc.Range(ref textStart, ref textEnd);
aDoc.Endnotes[1].Range = findE;
2) Add the hyperlink back to the section heading. This is most likely due to
my issue with the formatted text, but I have tried to work around it by using
a Find and trying to find the Endnote Text, but that isn't working either.
Are we not able to find Endnote Text programmatically? I tried a VBA macro as
well and it didn't work. Here is my C# approach:
Range findEndnote = aDoc.Content;
findEndnote.Find.Forward = true;
object objTrue = true;
object objEndnoteStyle = "Endnote Text";
object objEndnoteFind = aDoc.Styles.get_Item(ref objEndnoteStyle);
findEndnote.Find.set_Style(ref objEndnoteFind);
findEndnote.Find.Text = "Section";
findEndnote.Find.Execute(
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref objTrue, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);