Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Is there a forum that has a thread about free source code for a bibliography manager?
I just want to know how did they programmatically Insert a Citation with the corresponding bibliography of the inserted citation in word ,I tried this to make my own but my problem is instead of inserting the corresponding bibliography of the inserted citation my program insert all the bibliography in the document

I'm referring to EndNote,Zotero or something like that software.
I only need there code in inserting a citation

for example in Endnote bibliography manager software when they insert a citation it will insert a citation and the bibliography of the insert citation

example

if they insert a citaiton it will look like this

bla bla bla(Citation1)





(Bibliography1)
and if they insert again a citation so on and so fort
bla bla bla(Citation1)(Citation2)






(Bibliography1)
(Bibliography2)



I hope someone can give me a link or some source code to achieve it
I just really need it
I have code here in Inserting Citation and Bibliography but what happen in this code is it insert all of the bibliography and what I want is only the bibliography that correspond to the inserted citation will be inserted in the document like the example above.
by the way here's my code

C#
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);
            }
        }



Thank you in advance to someone who can help me about my problem
Posted
Updated 17-Jan-14 9:30am
v2
Comments
ZurdoDev 17-Jan-14 10:16am    
I had commented on one of your other questions if you had recorded a macro in Word doing what you want? You seem to want Word to do something specific so all you have to do is record a macro in Word doing what you want and you can see the code of how to do it.
Member 10174518 17-Jan-14 10:31am    
yes sir but when I insert a bibliography it will insert all of the sources,that's why I ask again hoping that someone know some thread or forum about my problem ,I made a program in c# but still it insert all of the bibliography sources.
I just wonder how did Endnote insert a citation and bibliography that correspond the inserted citaiton.
ZurdoDev 17-Jan-14 10:49am    
I don't fully understand what you want; however, can you do what you want in Word? If so, just record a macro.
Member 10174518 17-Jan-14 15:41pm    
every citation has a bibliography,now what I want is that I want to insert a citation and the corresponding bibliography into document programmatically,in my code that I provided above I can Insert a citation but the problem is that it insert all of the bibliography and like what I said i want only to insert the correspoding bibliography of the inserted citation to the document,I hope you can help me with this Sir,please check my code above Sir.
ZurdoDev 17-Jan-14 16:01pm    
Yes, you have said that over and over. What you have not done is answered my question. Is it possible to do what you want in Word using just Word?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900