Skip to content

The requested member of the collection does not exist ?

varun kumar

Asked Mar 2, 2011, 9:39 PM EST1 answer
Share
LinkedInX
                object oMissing = System.Reflection.Missing.Value;
                object ofileName = "E:\\Template.dotx";
                Word.ApplicationClass myWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
                Word.Document myWordDoc = myWordApp.Documents.Add(ref ofileName, ref oMissing, ref oMissing, ref oMissing);
                myWordApp.Visible = true;
                myWordApp.Activate();                                                                  // start Word
                Word.Paragraph oPara1;
                oPara1 = myWordDoc.Content.Paragraphs.Add(ref oMissing);
                oPara1.Range.Text = "Heading 1";
                oPara1.Range.Font.Bold = 1;
                oPara1.Format.SpaceAfter = 24;    //24 pt spacing after paragraph.
                oPara1.Range.InsertParagraphAfter();
                Word.Table oTable;
                object objr = myWordApp.Selection;
                Word.Range wrdRng = myWordDoc.Bookmarks.get_Item(ref ofileName).Range;


Actually i'm using word template file to create the new word file here.

It shows the error when the cursor come to last line.

I dont know how to solve this problem.

Please give me the solution to this problem

Thanks to all.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    If am not wrong you want to retrieve the bookmark from range. But, you are passing the file into method (last line) instead of bookmark.

    Do a web search, how to find bookmark from excel cell range.
    0