Click here to Skip to main content
16,004,227 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am using asp.net to create new word doc.

I have added microsoft office library 12.0 and namespace

using Microsoft.Office.Core;
using Microsoft.Win32.SafeHandles;
using Microsoft.Office.Tools.Word;
using Microsoft.Office.Tools.Word.Controls;
using Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using Microsoft.Office;


but still finding some errors.

I use Word/word in my code to create object and somewhere else following error shows..


The type or namespace name 'word' could not be found (are you missing a using directive or an assembly reference?)

Tell me if anyone knows what's the error is...
Posted
Updated 20-Aug-10 2:13am
v3
Comments
Dalek Dave 20-Aug-10 7:45am    
Minor Edit for Readability.

Why would you create a word doc in a website ? What makes you think this is an ASP.NET question ? It's a C# question, and an Office interop question. The code is no different b/c it runs in a website.

Your error looks to me like you typed 'word' instead of 'Word', C# is case sensitive. As you posted no code, it's hard to say any more. Your list of using statements is not where your error comes from, so it is irrelevant.

You're using IO, Reflection, Office and Win32 in a website ? This sounds like a fundamentally bad idea to me....
 
Share this answer
 
Comments
pronning300 20-Aug-10 8:14am    
i Have improved my Q to C#...
This is the code i am using to create a doc....

Microsoft.Office.Interop.Word.Application word = null;
// Opens new documentMicrosoft.Office.Interop.
word.Document doc = null;
// Instantiates Word applicationMicrosoft.Office.Interop.
word = new word.Application();
// Links to public website where the User Manual is located ( I wanna have the user manual on my desktop as I have not website.
object objFileName = "desktop";

// Keeps User Manual read-only
object objTrueValue = true;
// References to Word class exceptions used when showing error messages
object objMissing = Type.Missing;
// Shows Word application
word.Visible = true;
// Focuses on Word
word.Activate();

// Opens file and acts as an exception handler in Word
doc = word.Documents.Open(ref objFileName, ref objMissing, ref objTrueValue,
ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing);
// Focuses on User Manual opened in Word application
doc.Activate();
pronning300 20-Aug-10 8:34am    
Tell me which namespace i should add in my C# page..............
InvisibleArt 15-Feb-11 14:24pm    
"Why would you create a word doc in a website?"
In my case, I'm supporting an Internet Explorer interface to an Oracle database. Users want information from the database in a Word doc. I can't user interop; Microsoft warns against it, and besides, Word is not installed on the server. Examples I find for the XML SDK open a file, which security does not allow. I need to create the Word doc in memory, then open Word on the client side containing the document from memory. I've managed this with an HTML version of a Word document in a big string, but I can't embed images in the document with HTML. So, I'm looking for an XML solution, perhaps using a memory stream.
First of all - You need to download Office Primary Interop Assemblies
Office 2003 PIA can be found here


http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en[^]


But before you start with interop you might want to know that due to security issues, you won't be able to access Office Interop when running on IIS server due to security issues with asp.net user (usually IIS_USER or something like that) Which runs using Network Permissions and doesn't have access to office interop.

You might search google for an alternative to create doc.
I think I saw an open-xml SDK from microsoft to generate docx files from code.
 
Share this answer
 
Comments
pronning300 20-Aug-10 8:13am    
i have also installed this PIA.Primary interop assebliemes but still the following error exist ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900