473,406 Members | 2,549 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,406 software developers and data experts.

How to open word document in asp.net with C#

i have problem in opening the word document , it shows an error like could not open macro storage, please help me , thanks in advance
Aug 7 '06 #1
7 72401
Began
3
hi,

here is the code to open the word document.


add a COM reference to your project by right clicking in the solution explorer on References->Add Reference

Click on the COM tab and look for the Microsoft Word 9.0 Object Library

just declare the line below in your class:

Expand|Select|Wrap|Line Numbers
  1. private Word.ApplicationClass WordApp = new Word.ApplicationClass();
  2.  
  3.  
  4. if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
  5.   {
  6.      object fileName = openFileDialog1.FileName;
  7.      object readOnly = false;
  8.  
  9.        object isVisible = true;
  10.        object missing = System.Reflection.Missing.Value;
  11.        WordApp.Visible = true;
  12.  
  13.       Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref                  missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
  14.  
  15.         aDoc.Activate();
  16.  
  17. }
regards,
Began.
Aug 7 '06 #2
I did every thing what u given code, but runtime it throws an error " Could not open macro storage "
hi,

here is the code to open the word document.


add a COM reference to your project by right clicking in the solution explorer on References->Add Reference

Click on the COM tab and look for the Microsoft Word 9.0 Object Library

just declare the line below in your class:
Expand|Select|Wrap|Line Numbers
  1. private Word.ApplicationClass WordApp = new Word.ApplicationClass();
  2.  
  3.  
  4. if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
  5.   {
  6.      object fileName = openFileDialog1.FileName;
  7.      object readOnly = false;
  8.  
  9.        object isVisible = true;
  10.        object missing = System.Reflection.Missing.Value;
  11.        WordApp.Visible = true;
  12.  
  13.       Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref                  missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
  14.  
  15.         aDoc.Activate();
  16.  
  17. }
regards,
Began.
Aug 7 '06 #3
I did every thing what u given code, but runtime it throws an error " Could not open macro storage "
Did you get to solve this issue? If you have I am very interested to know how you did it because it is driving me nuts. I have tried everything I could possibly find on the website and more. Help please if you can.
Sep 21 '06 #4
radcaesar
759 Expert 512MB
Hi,

the account running the web app (network service) needs access to the Word COM object

use dcomcnfg.msc
Sep 21 '06 #5
sandu
2
as you said the user account under which runs the asp.net don't have enough rights to call in execution the MS Word. One way is of course to use dcomconfig enable the asp.net but what if somebodey tries to hack you? you should use impersonation because is more safe.
Sep 21 '06 #6
longia
1
when we try to open word document with the help of code given by you, it does not open the information in header and footer. please help how we can read header and footer of the document also.
Sep 28 '06 #7
when we try to open word document with the help of code given by you, it does not open the information in header and footer. please help how we can read header and footer of the document also.
Expand|Select|Wrap|Line Numbers
  1. if( Request.QueryString["strFile"] != null )
  2. {
  3.   string strFilePath1="";
  4.   string strFileName = Request.QueryString["strFile"].ToString();
  5.   strFilePath1=Request.PhysicalApplicationPath+"/BackOffice/Catalogue/UploadFiles/"+strFileName;
  6.   if(strFileName!="")
  7.   {
  8.     Response.ContentType=strFilePath1;
  9.     Response.AddHeader("content-disposition", "attachment;filename="+strFileName);
  10.     Response.WriteFile(strFilePath1);                                
  11.   }
  12. }


Regards,

R.Ganesan
Sep 29 '06 #8

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

Similar topics

1
by: Vikas Kumar | last post by:
how to open word document and pdf file in aspx page
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
2
by: Alan T | last post by:
In my C# application, I want to open a Word document using the code from the Help: using Microsoft.Office.Interop.Word; object readOnly = true; object fileName = @"C:\Test\NewDocument.doc"; ...
10
by: Antoine De Groote | last post by:
Hi there, I have a word document containing pictures and text. This documents holds several 'ABCDEF' strings which serve as a placeholder for names. Now I want to replace these occurences with...
2
by: sbettadpur | last post by:
hello everybody, i want to open word document file in browser, it means there will be one hyperlink if i click(ex: it's file.doc) on that it has to open the file in the browser. thanks
2
by: alok5505 | last post by:
Hi All , I am new to Mobile development. I want to open word document in mobile control. Also I should be able to edit and save it. Is it possible to do it ? I am using Microsoft .NET...
1
by: shanmugamit | last post by:
i want open word document in frame but its ask open or save file..not open in frame....here is my code <frameset cols="120,*"> <frame src='sample.html'> <frame name='openfile' src='sample.doc'>...
7
by: Peter | last post by:
ASP.NET 2.0 I am trying to open a Word document and Excel document from a dialog web page, what's the best way to do that? I have tried the following: Response.Clear();...
7
by: Peter | last post by:
I have the following code which is executed from a modal web page - it works fine on most, but on some computers the Word loads into memory but never displays. This occurs with IE6 and IE7, but...
2
by: saketmayur | last post by:
Hi , I have write the following code to open word document on server using Microsoft.Office.Interop.Word; string DocPath = System.Configuration.ConfigurationManager.AppSettings; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.