Microsoft.Office.Interop.Word

Last post 07-10-2008 1:56 AM by TATWORTH. 28 replies.

Sort Posts:

  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 2:40 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     First question - does Word run on that machine?

    Second question - when you add the reference within the project, are selecting the COM tab and waiting for it to populate?

    I suggest that you put the Word Document reasding code into a separate class project. This will allow you test it using a WinForms test harness and / or unit test it before calling from your web project.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 2:51 AM

    Yes the word application(2003) is running on this machine.

    Yes i am referening the Microsoft object 11.o object library from COM tab.

    I created new project(Winforms) and when i  add the reference i got Microsoft.Office.Core dll.

  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 2:55 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     What are the symptoms of it not working?
    Have you checked the event logs? If there is an activation problem, it should be logged in the even t log.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 3:03 AM

    When i refer from the dll from using browse tad and refer the Microsoft.Office.Interop.Word dll from the location where i extracted the oxppia file then the reference will be added to windows application but not to the website.

  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 5:34 AM

    HI  i am able to refer to the dll to my website also my problem is resolved now. One more thing do i need to always download this oxppia.exe and then register them or will these PIAs be installed during word installation if so how do i go about doing this. Please let me know about this since in the server i just refffered to the COM object directly without downloading and register them

  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 7:30 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     I do not recall the PIA being automatically installed when Word is installed. For each installation, you will need to specify at the minimum:

    1. Install Word
    2. Install PIA
    3. Start up word on the machine.
    4. Check for COM+ permission messages in the event logs. 
    My recollection for setting this up is the need to set a lot of permissions in the COM+ explorer. This is best done using a virtual machine as you can easily revert to the start situation and repeat the process until you have reduced the setup to the essential changes.
    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 8:38 AM

    Hi thank you i am able to refer to the dll(Microsoft office 11.0 object library) finally. Now i have got an exception in the code saying "the command is not available" I ill send you the code i didn get this.

    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   }
    
  • Re: Microsoft.Office.Interop.Word

    07-08-2008, 9:14 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     Lines 8 through 38 need to be within a method in a class project

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Microsoft.Office.Interop.Word

    07-09-2008, 2:46 AM

    This error i got when i open a document which is protected. When i remove the protection it works fine. Is there any method to execute this without removing the protection. Or can i place this image in a place which is a macro(image)

     

  • Re: Microsoft.Office.Interop.Word

    07-09-2008, 2:54 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     By protected, do you mean the file is read-only?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Microsoft.Office.Interop.Word

    07-09-2008, 3:20 AM

    No not readonly my document consists of formfields and macros(image). This formfields are enabled only when we protect the document based on filling in form restriction. I now want to add an image to the Image macro programmatically.

  • Re: Microsoft.Office.Interop.Word

    07-09-2008, 3:55 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     If it is internal to the document, then you will need to further delve into the Word Object Model and either post a further question on this forum and/or post a question on one of the MSDN forums.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Microsoft.Office.Interop.Word

    07-10-2008, 1:16 AM

    Hi the above code which i have snet is inserting an image above the text. Can u please let me know how  to insert it below a text.

  • Re: Microsoft.Office.Interop.Word

    07-10-2008, 1:56 AM
    • Loading...
    • TATWORTH
    • Joined on 02-04-2003, 8:34 AM
    • England
    • Posts 7,113

     Again you will need to delve into the word Object model and find a way to move the insertion point down one line.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Page 2 of 2 (29 items) < Previous 1 2