none
Saving Bibliography Sources RRS feed

  • Question

  • Hi,

    I want to know how to save bibliography sources using c# programmatically
    anyone knows any article or forum to help me with this
    please help

    Thank you in advance
    More Power
    God Bless

    Wednesday, December 18, 2013 10:52 AM

Answers

  • Hi,

    According to your earlier post: Microsoft Word add-in adding bibliography style, you are developing a VSTO Add-in for Word.

    What do you mean by “save bibliography sources”?

    Do you want to implement similar functionality of Word feature “Manage Sources”?

    As far as I know, bibliography sources contains two types of sources:

    Master list and Current list.

    To add a source to the master source list, you access the Sources collection from the Bibliography property of the Application object. To add a source to the current source list, access the Sources collection from the Bibliography property of the Document object.

    For more information, please refer to Working with Bibliographies.

    The article provided VBA code to add bibliography sources, it is similar to use C#.

    Here is a sample to add or delete bibliography sources by clicking a button in ribbon:

    private void button2_Click(object sender, RibbonControlEventArgs e)
            {
                string strXml = "<b:Source xmlns:b='http://schemas.microsoft.com/office/word/2004/10/bibliography'><b:Tag>Mor01</b:Tag><b:SourceType>Book</b:SourceType><b:Author><b:Author><b:NameList><b:Person><b:Last>Hezi</b:Last><b:First>Mor</b:First></b:Person></b:NameList></b:Author></b:Author><b:Title>The New Office</b:Title><b:Year>2006</b:Year><b:City>Seattle</b:City><b:Publisher>Adventure Works Press</b:Publisher></b:Source>";
                //Globals.ThisAddIn.Application.Bibliography.Sources[1].Delete();
                Globals.ThisAddIn.Application.Bibliography.Sources.Add(strXml);
                //Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources[1].Delete();
                Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources.Add(strXml);
            }

    If you want to implement similar functionality of Word feature “Manage Sources”, you need to create a similar form as the figure, display the form by a ribbon control click event like this:

    private void button2_Click(object sender, RibbonControlEventArgs e)
            {
                Form1 f1 = new Form1();
                f1.ShowDialog();
            }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 19, 2013 9:48 AM
    Moderator

All replies

  • Hi,

    According to your earlier post: Microsoft Word add-in adding bibliography style, you are developing a VSTO Add-in for Word.

    What do you mean by “save bibliography sources”?

    Do you want to implement similar functionality of Word feature “Manage Sources”?

    As far as I know, bibliography sources contains two types of sources:

    Master list and Current list.

    To add a source to the master source list, you access the Sources collection from the Bibliography property of the Application object. To add a source to the current source list, access the Sources collection from the Bibliography property of the Document object.

    For more information, please refer to Working with Bibliographies.

    The article provided VBA code to add bibliography sources, it is similar to use C#.

    Here is a sample to add or delete bibliography sources by clicking a button in ribbon:

    private void button2_Click(object sender, RibbonControlEventArgs e)
            {
                string strXml = "<b:Source xmlns:b='http://schemas.microsoft.com/office/word/2004/10/bibliography'><b:Tag>Mor01</b:Tag><b:SourceType>Book</b:SourceType><b:Author><b:Author><b:NameList><b:Person><b:Last>Hezi</b:Last><b:First>Mor</b:First></b:Person></b:NameList></b:Author></b:Author><b:Title>The New Office</b:Title><b:Year>2006</b:Year><b:City>Seattle</b:City><b:Publisher>Adventure Works Press</b:Publisher></b:Source>";
                //Globals.ThisAddIn.Application.Bibliography.Sources[1].Delete();
                Globals.ThisAddIn.Application.Bibliography.Sources.Add(strXml);
                //Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources[1].Delete();
                Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources.Add(strXml);
            }

    If you want to implement similar functionality of Word feature “Manage Sources”, you need to create a similar form as the figure, display the form by a ribbon control click event like this:

    private void button2_Click(object sender, RibbonControlEventArgs e)
            {
                Form1 f1 = new Form1();
                f1.ShowDialog();
            }


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 19, 2013 9:48 AM
    Moderator
  • Hi Sir George,

    I'm really sorry for the late reply 'cause I was in Christmas vacation that's why I haven't check my thread,Sir Thank you very much for your reply I will try this now..

    Once again Sir George Thank you very much
    More Power!
    God Bless you Sir
    Saturday, December 28, 2013 10:40 AM
  • Hi,

    I want to make an add-in similar to Manage Source in the reference tab of Microsoft Word,I have code for adding Bibliography sources but it gave me and error

    here is the code

    private void button2_Click(object sender, RibbonControlEventArgs e)
            {
                string strXml = "<b:Source xmlns:b='http://schemas.microsoft.com/office/word/2004/10/bibliography'><b:Tag>Mor01</b:Tag><b:SourceType>Book</b:SourceType><b:Author><b:Author><b:NameList><b:Person><b:Last>Hezi</b:Last><b:First>Mor</b:First></b:Person></b:NameList></b:Author></b:Author><b:Title>The New Office</b:Title><b:Year>2006</b:Year><b:City>Seattle</b:City><b:Publisher>Adventure Works Press</b:Publisher></b:Source>";
               
                Globals.ThisAddIn.Application.Bibliography.Sources.Add(strXml);
               
                Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources.Add(strXml);
            }

    and I want it the same form in the Manage Source but I don't know how to show the Master List and the Current List

    if someone knows it please help me


    • Edited by iGnjmz Friday, January 3, 2014 2:33 PM
    • Merged by Cindy Meister MVPModerator Saturday, January 4, 2014 3:42 PM apparently same question as refers to the target discussion and "does not understand" the answer, but does not mention this in the target discussion
    Friday, January 3, 2014 2:32 PM
  • Hi iGnjmz,

    Though I am not familiar with a Bibliography Citation in Word, you may be interested in the following articles:

    >> but it gave me and error

    What error or exception do you get? Did you try to debug?

    Saturday, January 4, 2014 2:41 PM
  • Hi Sir Eugene,

    Thank you for your reply Sir,It gave me this exception Sir " COMException was unhandled by user code "
     Error 0x800A1837 handling XML data

    That's it Sir and someone told me how to do it but unfortunately I'm confused in doing what he mean :(

    here's the link Sir : http://social.msdn.microsoft.com/Forums/office/en-US/9c192414-7147-489d-8aeb-947d2a0d041e/saving-bibliography-sources?forum=worddev#a02f81ac-5ba1-4ae7-96bc-5681115f8c7c

    Once again Sir Thank you
    More Power
    God Bless you

    Saturday, January 4, 2014 3:18 PM
  • Hi,

    I want to know how to access the Sources collection from the Bibliography property of the application object so that I can add a new Bibliography source to the master list of the Bibliography Sources and I want to know also how to access Sources collection from the Bibliography property of the Document object so that I can add a  Bibliography Source to the Current List,I want to this in c# with a form like a Manage Source in the reference tab in MS word.

    Please reply to this thread if you know it please.

    • Merged by Marvin_Guo Monday, January 6, 2014 7:42 AM The same issue
    Sunday, January 5, 2014 2:51 PM
  • Hi,

    The error happened because there was already a source existing with the same tag name:

    What you need to do is to judge whether the source with the same Tag name already existing before adding new Bibliography.

    For example:

    if (Globals.ThisAddIn.Application.Bibliography.Sources[2].Tag != "Mor01")

    >>but I don't know how to show the Master List and the Current List<<

    Add two list box controls for the Master List and the Current List, loop all source of Bibliography then insert into the correspondent listbox.

    The Master List matches Globals.ThisAddIn.Application.Bibliography.Sources

    The Current List matches Globals.ThisAddIn.Application.ActiveDocument.Bibliography.Sources


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 6, 2014 7:38 AM
    Moderator
  • Hi Sir Geourge,

    Sorry Sir but I wasnt able to make a Create Source like form in my project that's why I didn't know that the tag was already exist,but I read some article that I can use a built-in dialog box but when I use the sample code it gave me some error and I try to fix it but no luck,So maybe I can use the built-in dialog box of Manage Source in order for me to use the code you gave me which is adding bibliography source.

    By the way Sir Thank you very much I hope you will still help me with my problem
    More Power to you
    and God Bless. 
    Monday, January 6, 2014 3:54 PM