MS Word addin written in C#- Word._Document.SaveAs read only problem

P

Petyo Milotinov

Hello!
I'm developing a MS Word 2002 (version 10) addin in C# using interop
services.
I save a copy of the document using Word._Document.SaveAs API function:

object fileName = FileName;
object fileFormat = Word.WdSaveFormat.wdFormatHTML;
object lockComments = Type.Missing;
object password = Type.Missing;
object addToRecentFiles = Type.Missing;
object writePassword = Type.Missing;
object readOnlyRecommended = false;
object embedTrueTypeFonts = Type.Missing;
object saveNativePictureFormat = Type.Missing;
object saveFormsData = Type.Missing;
object saveAsAOCELetter = Type.Missing;
object encoding = Type.Missing;
object insertLineBreaks = Type.Missing;
object allowSubstitutions = Type.Missing;
object lineEnding = Type.Missing;
object addBiDiMarks = Type.Missing;

wordDoc.SaveAs( ref fileName, ref fileFormat, ref lockComments, ref
password, ref addToRecentFiles, ref writePassword,
ref readOnlyRecommended, ref embedTrueTypeFonts, ref
saveNativePictureFormat, ref saveFormsData, ref saveAsAOCELetter,
ref encoding, ref insertLineBreaks, ref allowSubstitutions, ref
lineEnding, ref addBiDiMarks);

The problem appears when I call this code for a second time. The SaveAs
API throws an exception "This file is read-only.(filename.html)". That file
(filename.html) actually is not readonly but it is used by WinWord.exe- I
can't modify or delete it outside the MS Word.
So, where is the problem and how can I get around it?
Thanks in advance!

Best regards,
Petyo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top