private void InsertCitation_Click(object sender, RibbonControlEventArgs e)
{
// Insert a citation after the text just inserted to the bibliography
// source added previously.
Application wordApplication = Globals.ThisAddIn.Application;
//wordApplication.Selection.EndKey(ref paramWdUnits,ref paramWdMovementType);
wordApplication.Selection.Fields.Add(wordApplication.Selection.Range,
ref paramWdFieldTypeCitation, dropDown1.SelectedItem.Label,//ref paramBiblioSourceTag,
ref paramMissing);
// wordApplication.Selection.Fields.Add(wordApplication.Selection.Range,
// ref paramWdFieldTypeCitation,
// ref paramBiblioSourceTag,ref paramMissing);
// Insert a page break after the citation added previously and then
// add a bibliography to the document.
Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
Word.Range rng = doc.Content;
object oCollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;
rng.Collapse(ref oCollapseEnd);
wordApplication.Selection.EndKey(ref paramWdUnits, ref paramWdMovementType);
wordApplication.Selection.InsertBreak(WdBreakType.wdLineBreak);
//If find the Bibliography field in the document then update the field
//otherwise insert a Bibliography field
bool isFoundFieldBibliography = false;
foreach (Field field in wordApplication.ActiveDocument.Range().Fields)
{
if (field.Type == WdFieldType.wdFieldBibliography)
{
isFoundFieldBibliography = true;
//update BibliographyField
field.Update();
}
}
if (!isFoundFieldBibliography)
{
wordApplication.Selection.Fields.Add(wordApplication.Selection.Range,
ref paramWdFieldTypeBiblio, ref paramMissing, ref paramMissing);
}
}private void RefreshBibliography_Click(object sender, RibbonControlEventArgs e)
{
Refresh_Bibliography();
}
private void Refresh_Bibliography()
{
this.dropDown1.Items.Clear();
foreach (Source source in Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources)
{
RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
item.Label = source.Tag;
this.dropDown1.Items.Add(item);
}
}