473,230 Members | 1,410 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,230 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 72359
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.