Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#

Hi,

I'm creating a word file using File Operation.

Later i'm opening the file, some time i'm getting message like,

.doc is locked for editing by user. see my below code,

C#
Word.Application wdApp = new Word.Application();
object obj = System.Type.Missing;
object docPath = bData.Path;
wdApp.Documents.Open(ref docPath, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj, ref obj);



So, after doing my changes i'm getting error in the save as method,

C#
wdDoc.SaveAs(ref objDoc, ref obFormat, 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, ref objMissing);


I'm getting error like ,

Word cannot complete the save due to a file permission error.

please help me.
Posted

1 solution

These are not issues that can be fixed by code. You need to investigate why the file is locked in case 1, and why you are not allowed to save in a particular directory in case 2.
 
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