Converting Endnote to Footnote
Hi All,
I have a problem with converting endnote to footnote, My idea is
1. Get all the endnotes to the array
2. Get all endnote references
3. Is it match then im going to insert footnote.
var endParas=new Array();
var oldContents="";
aDoc=app.activeDocument;
for(var pg=0; pg < aDoc.pages.count(); pg++)
{
var page=aDoc.pages.item(pg);
for(var tf=0; tf < page.textFrames.count(); tf++)
{
var textFrame=page.textFrames.item(tf);
for(var para=0; para < textFrame.paragraphs.count(); para++)
{
myPara=textFrame.paragraphs.item(para);
if (String(myPara.appliedParagraphStyle.name).match(/Endnotes/))
{
myContents=myPara.contents;
if (myContents != oldContents && myContents !="")
{
if (String(myContents).match(/\d+\t/ig))
{
endParas.push(myPara);
}
oldContents=myPara.contents;
}
}
}
}
}
app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.findWhat="\\d+";
app.findGrepPreferences.position = Position.superscript;
var matchedItems=aDoc.findGrep();
if (matchedItems.length == endParas.length)
{
var myFootnotes=new Array();
for (var mtch=0; mtch < matchedItems.length; mtch++)
{
matchedItems[mtch].select();
app.selection[0].contents="";
myFoot=app.selection[0].insertionPoints[0].footnotes.add();
endParas[mtch].texts[0].move(LocationOptions.after, myFoot.insertionPoints[myFoot.insertionPoints.length-1]);
}
}
else
{
alert('Endnote citations and notes not equal, so it will not run');
exit(0);
}
What was the problem here is, when im inserting the footnote 'endParas' array automatically changing the paragraphs, so we won't get correct endnote paragraph.
Anybody have other ideas, pls let me know.
Regards,
sudar