Click here to Skip to main content
15,949,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am reading data from word document by opening the document

C#
                    Word.Document docTemp = wordApp.Documents.Open(ref fileName, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
localPath = fileName.ToString().Substring(fileName.ToString().LastIndexOf("\\"));

                    docTemp.SaveAs("E:" + localPath + ".html", Word.WdSaveFormat.wdFormatFilteredHTML, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    saveAsFileName = "E:" + localPath + ".html".ToString();
                    ((Word.Document)docTemp).Close(ref doNotSaveChanges, Missing.Value, Missing.Value);


i am getting error locked by admin.
Posted
Updated 10-Aug-12 10:21am
v2
Comments
[no name] 10-Aug-12 16:25pm    
http://answers.microsoft.com/en-us/office/forum/office_2003-word/ms-word-2003-locked-for-editing-by-admin-account/d456b20b-c2aa-43fc-9022-80cdd4b4c164
Maciej Los 10-Aug-12 16:28pm    
What's the problem? What oyu mean "im getting error locked by admin"?
Your code seems to be OK. After opening the document, you save it as html and close it without saving...

1 solution

Locked by admin could simply mean that someone else has opened the document, this could be avoided by copying the document temporararly to your local hard drive. This could be done with this code:
http://msdn.microsoft.com/en-us/library/cc148994.aspx[^]

Now you simply proced to open your local copy and read out the text :)
 
Share this answer
 

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