473,327 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Namespace Error Using Microsoft.Office.Interop.Word;

2
Hi,

I use this program to sort the images in word document. in this i try to get the input as MS Word document.

while compiling it ends with namespace error

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Word = Microsoft.Office.Interop.Word;
  5.  
  6. namespace WindowsFormsApplication1
  7. {
  8.     class WindowsFormsApplication1
  9.     {
  10.         #region Constructor
  11.         public WindowsFormsApplication1()
  12.         {
  13.             WordApp = new Microsoft.Office.Interop.Word.Application();
  14.         }
  15.         #endregion
  16.  
  17.         #region Fields
  18.         private Word.Application WordApp;
  19.         private object missing = System.Reflection.Missing.Value;
  20.         private object yes = true;
  21.         private object no = false;
  22.         private Word.Document d;
  23.         private object filename = @"C:\Data\example.doc";
  24.         #endregion
  25.  
  26.         #region Methods
  27.         public void UpdateDoc()
  28.         {
  29.             d = WordApp.Documents.Open(ref filename, ref missing, ref no, ref missing,
  30.                ref missing, ref missing, ref  missing, ref  missing, ref  missing,
  31.                ref  missing, ref missing, ref yes, ref  missing, ref  missing, ref  missing, ref  missing);
  32.             List<Word.Range> ranges = new List<Microsoft.Office.Interop.Word.Range>();
  33.             foreach (Word.InlineShape s in d.InlineShapes)
  34.             {
  35.                 if (s.Type == Microsoft.Office.Interop.Word.WdInlineShapeType.wdInlineShapePicture)
  36.                 {
  37.                     ranges.Add(s.Range);
  38.                     s.Delete();
  39.                 }
  40.             }
  41.             foreach (Word.Range r in ranges)
  42.             {
  43.                 r.InlineShapes.AddPicture(@"C:\Photo\Image.jpg", ref missing, ref missing, ref missing);
  44.             }
  45.             WordApp.Quit(ref yes, ref missing, ref missing);
  46.         }
  47.         #endregion
  48.  }
  49. }
How to resolve this?
Apr 21 '12 #1
3 3519
RhysW
70
I see this got answered in your msdn version of the question, though that problem is not replicated here as you have the correct capitalising on word, though ironically that may have been the spell checker in the code poster that made you update it, fixing your code for you.
Apr 24 '12 #2
adriancs
122 100+
dont use Microsoft.Office.Interop.Word,
use Open XML SDK 2.0
Jul 3 '12 #3
PsychoCoder
465 Expert Mod 256MB
I suggest using Microsoft.Office.Interop.Word as then you're using something native in the language/framework.

What is the exact error you're getting?
Jul 3 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bracoute | last post by:
Hello.... can you plz help me ... i'm using vbscript in asp.net and i've referenced the microsoft.office.interop.word.dll so that i can use the wordApplication object to automate MS Word.. the...
1
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
1
by: Alan T | last post by:
VS 2005 and MS Office 2003 installed. I can include Microsoft.Office.Core and Word in the references so I can add the using Microsoft.Office.Interop.Word. However, my workmate cannot do the...
9
by: sajithkahawatta | last post by:
my web page C#.net is work properly in my iis .but when i publish in another server it give errers.i used vs2005 and ms word 2003. but in the server there is no vs2005 or word installed. it has only...
0
by: chovatia.jaydeep | last post by:
Hi, I want to hide Menubar/Toolbar in Word/Excel 2007. I followed steps given in the link: http://msdn2.microsoft.com/en-us/library/aa338202.aspx Following above linke, i created Add-In...
0
by: kalyanilovesme | last post by:
how to import that name space(Microsoft.Office.Interop.Word) in asp.net with c#.. i added the reference of microsoft.office11.0.object library even though this name space not coming...
1
by: mac73 | last post by:
Hi, I am using asp.net 2.0 application with Microsoft.Office.Interop.Word version 11.0.0.0 on windows server 2003 with IIS 6.0. It works fine with access given to Network service. The scenario...
1
by: PulkitZery | last post by:
Hello! I am looking to find Microsoft.Office.Interop.Word dll for Office 2007, to include it into my project’s bin folder. I tried to download it from : ...
0
by: jojee | last post by:
Hi All i have a little problem in my project that is i m using word document for reading the contents from it so i did add the references Microsoft.Word.Object library and in the wen.config file i...
5
by: Alex Dransfield | last post by:
I am trying to add text to a shape but I can't figure out how to do it.. I am using the method public void DrawOnDoc(object oMissing, Microsoft.Office.Interop.Word._Document oDoc) { ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.