Problems with Word Automation in ASP.NET

I have the below code. I am trying to insert some text into a predefined MSWord template that has a table in it. In my project I have references to the following  .dlls. (Microsoft.Office.Core.dll, Microsoft.Office.Interop.Word.dll) I get the following error when trying to refer to the cells of the table:

"Microsoft.Office.Interop.Word.Tables' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'Microsoft.Office.Interop.Word.Tables' could be found (are you missing a using directive or an assembly reference?)"

This seems like I am missing an assembly reference but I have done a lot of reading on the dlls needed for automation in and it is kind of confusing in trying to discern what it is I need. Office 2003 is installed on my local where I am running this from. Any advice would be greatly appreciated.

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office;
using Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Runtime;
using System.Data;
using Word = Microsoft.Office.Interop.Word;
namespace CodeProjectAutomation
    public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        protected void Button1_Click(object sender, EventArgs e)
            // Handle parameters you don't care about in .NET        
            object oMissing = System.Reflection.Missing.Value;
            // Predefined bookmark
            object oEndOfDoc = "\\endofdoc";
            // Launch MS Word
            Word._Application oWord;
            Word._Document oDoc;
            oWord = new Word.Application();
            // Get the document template (.DOT) file
            object objDocTemplate = Server.MapPath("") + "\\MyTemplate\\";
            oDoc = oWord.Documents.Add(ref objDocTemplate, ref oMissing, ref oMissing,
                ref oMissing);
            // Forcefully hide the table GridLines
            oDoc.ActiveWindow.View.TableGridlines = false;
            // Forcefully set the Zoom percentage to 100% when opening the document
            oDoc.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
            // Forcefully hide the Spelling Errors
            oDoc.ShowSpellingErrors = false;
            // Add text data to the cells in the Table (This can be static data or 
            // data retrieved from database)
            oDoc.Tables.Item(1).Cell(1, 1).Range.Text = "My Document's Title";
            oDoc.Tables.Item(1).Cell(2, 1).Range.Text = "My Document Description";
            oDoc.Tables.Item(1).Cell(3, 1).Range.Text = "My Image Name";
            // Save opened template as another .doc file
            Object oSaveAsFile = Server.MapPath("") + "\\MyTemplate\\MyDocument.doc";
            oDoc.SaveAs(ref oSaveAsFile, ref oMissing, ref oMissing, ref oMissing,
                               ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                               ref oMissing, ref oMissing, ref oMissing);
            // Close the document, destroy the object and Quit Word
            object SaveChanges = true;
            oDoc.Close(ref SaveChanges, ref oMissing, ref oMissing);
            oDoc = null;
            oWord.Quit(ref SaveChanges, ref oMissing, ref oMissing);

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try get_Item. I think that's fairly standard when automating Office apps
from C#:

wd.Range rng = wdDoc.Bookmarks.get_Item(ref objBkmName).Range;

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.