none
how to control the position of the text RRS feed

  • Question

  • Hi,

    why is it that if I run my program the text which is "Reference" always at the end of the document,I'm really stuck in this problem,can anyone explain why this happening and can you tell me the code to solve this? I'm really need help please.

    by the way here's the code

    private void btmInsertCitation_Click(object sender, EventArgs e)
            {
                Tagg tag1 = listBox1.SelectedItem as Tagg;
    
                Microsoft.Office.Interop.Word.Application wordApplication = Globals.ThisAddIn.Application;
                wordApplication.Selection.Fields.Add(wordApplication.Selection.Range,
                    ref paramWdFieldTypeCitation, tag1.Tag,
                    ref paramMissing);
     
                wordApplication.Selection.EndKey(ref paramWdUnits, ref paramWdMovementType);
                wordApplication.Selection.InsertBreak(WdBreakType.wdPageBreak);
                //Insert a text before the Bibliography
                Word.Range rng = wordApplication.Selection.Range;
                rng.Text = "Reference";
                rng.Font.Bold = -1;
                rng.Font.Size = 20;
                rng.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
    
                bool isFoundFieldBibliography = false;
                foreach (Field field in wordApplication.ActiveDocument.Range().Fields)
                {
                    if (field.Type == WdFieldType.wdFieldBibliography)
                    {
                        isFoundFieldBibliography = true;
                        field.Update();
                    }
                }
                if (!isFoundFieldBibliography)
                {
                    wordApplication.Selection.Fields.Add(wordApplication.Selection.Range,
                    ref paramWdFieldTypeBiblio, ref paramMissing, ref paramMissing);
                }
                wordApplication.Selection.PreviousField().Select();
                wordApplication.Selection.PreviousField().Select();
                wordApplication.Selection.MoveRight(WdUnits.wdCharacter, 1);
                this.Close();
            }

    please help me I'm really stuck at the problem :(

    thank you in advance to those who will help

    more power

    Gob Bless us all

    Wednesday, February 12, 2014 6:23 PM

All replies

  • What values are you passing to the following method as parameters?

       wordApplication.Selection.EndKey


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, February 12, 2014 6:37 PM
    Moderator
  • Hi Ma'am Cindy,

    I'm sorry Ma'am but I don't know,maybe its a wdLine and a wdMove

    I'm really sorry Ma'am,I'm not sure :(


    • Edited by iGnjmz Wednesday, February 12, 2014 7:05 PM
    Wednesday, February 12, 2014 6:44 PM
  • Could you give us a workable sample?

    I tried to run your code in a Word Add-in, there are many errors.

    'paramWdFieldTypeCitation', 'paramWdFieldTypeBiblio','Tagg' etc..

    Friday, February 14, 2014 10:02 AM