i have problem in opening the word document , it shows an error like could not open macro storage, please help me , thanks in advance
How to open word document in asp.net with C#
Collapse
X
-
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:
regards,Code:private Word.ApplicationClass WordApp = new Word.ApplicationClass(); if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { object fileName = openFileDialog1.FileName; object readOnly = false; object isVisible = true; object missing = System.Reflection.Missing.Value; WordApp.Visible = true; 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); aDoc.Activate(); }
Began.Last edited by Frinavale; Dec 9 '09, 07:43 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags. -
I did every thing what u given code, but runtime it throws an error " Could not open macro storage "
Originally posted by Beganhi,
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:
regards,Code:private Word.ApplicationClass WordApp = new Word.ApplicationClass(); if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { object fileName = openFileDialog1.FileName; object readOnly = false; object isVisible = true; object missing = System.Reflection.Missing.Value; WordApp.Visible = true; 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); aDoc.Activate(); }
Began.Comment
-
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.Originally posted by vijayat23I did every thing what u given code, but runtime it throws an error " Could not open macro storage "Comment
-
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.Comment
-
Originally posted by longiawhen 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.Code:if( Request.QueryString["strFile"] != null ) { string strFilePath1=""; string strFileName = Request.QueryString["strFile"].ToString(); strFilePath1=Request.PhysicalApplicationPath+"/BackOffice/Catalogue/UploadFiles/"+strFileName; if(strFileName!="") { Response.ContentType=strFilePath1; Response.AddHeader("content-disposition", "attachment;filename="+strFileName); Response.WriteFile(strFilePath1); } }
Regards,
R.GanesanLast edited by Frinavale; Dec 9 '09, 07:45 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.Comment
Comment