Urgent: How to add reference to Microsoft.Office.Interop.Word

Last post 07-08-2008 6:27 AM by Geetha Naidu C. P.. 2 replies.

Sort Posts:

  • Urgent: How to add reference to Microsoft.Office.Interop.Word

    07-08-2008, 1:15 AM

    Hi all,

    I am working on asp.net website for word automation. When i add a reference to Com object microsoft office 11.0 object library the referenceis not being added. How to solve this problem, i think its an issue with the registration of this library in GAC. Please can any one help me in solving this problem step by step

     

  • Re: Urgent: How to add reference to Microsoft.Office.Interop.Word

    07-08-2008, 3:07 AM
    • Loading...
    • Satyabrat
    • Joined on 02-01-2008, 1:19 PM
    • Posts 104

    Hello  Geetha

    http://support.microsoft.com/kb/823996

    Also, you may need to add a reference in your project to Microsoft.Office.Interop.Word.dll.

     

    if u have any query fill free to reply. 

    Satyabrat Singh
    B.E.(C.Sc.)
    Web developer
    Livetek Solution
    Dont forget to click "Mark as Answer" on the post that helped you.
  • Re: Urgent: How to add reference to Microsoft.Office.Interop.Word

    07-08-2008, 6:27 AM

    Hi thank you i am able to refer to the dll finally. Now i have got an exception in the code saying "the command is not available" I ill send you the code please do verify it 

    1    protected void btnUpload_Click(object sender, EventArgs e)
    2        {
    3            if (FileUpload.HasFile)
    4            {
    5                if (FileUpload.PostedFile.FileName.EndsWith(".doc"))
    6                {
    7                    string strFilename = FileUpload.PostedFile.FileName;
    8                    object objFileName=strFilename;
    9                    object missing =Missing.Value;               
    10                   Word.ApplicationClass wordApp = new Word.ApplicationClass();
    11                   Word.Document doc = wordApp.Documents.Open(ref objFileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
    12                   doc.Activate();
    13                   object objWrap=Word.WdFindWrap.wdFindStop;
    14                   Word.Range storyRange;
    15                   foreach (Word.Range rng in doc.StoryRanges)
    16                   {
    17                       storyRange = rng.Duplicate;
    18                       do
    19                       {
    20                           Word.Range findRange = storyRange.Duplicate;
    21                           if (findRange.Text != "")
    22                           {
    23                               findRange.Find.Text = "Yours truly,";                        
    24                               findRange.Find.Wrap=(Word.WdFindWrap)objWrap;
    25                               (Here i will get the Exception)findRange.Find.ExecuteOld(ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing,ref missing);//, ref missing, ref missing, ref missing, ref missing);
    26                               if (findRange.Find.Found == true)
    27                               {
    28                                   object objUnit = Word.WdUnits.wdWord;
    29                                   object count=1;
    30                                   object rngAdd = findRange.Duplicate;
    31                                   findRange.Move(ref objUnit, ref count);
    32                                   findRange.GoToNext(Word.WdGoToItem.wdGoToLine);
    33                                   findRange.InlineShapes.AddPicture(@"C:\Documents and Settings\support\Desktop\canaryslogo.jpg", ref missing, ref missing, ref rngAdd);
    34                               }
    35                           }
    36                           storyRange = findRange.NextStoryRange;
    37                       }while(storyRange!=null);
    38                   }
    39               }
    40           }
    41   }
    
     
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter