Hi
I am automate the convertion all my documents into text file which resides in a folder.
some of the document are been password protected.
so while i am opening the document it show an alert as shown in attached image.
it interupts the automated conversion and ask for manual intervention
i need to supress those alerts display. or i want those document which are password protected to be skipped
can help me to overcome the issue
here is my code
private void TextFileConvertion(string strsource, string strtarget)
{
object Unknown = Type.Missing;
Word.Application newApp = new Word.Application();
Word.Document doc = null;
newApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
try
{
lblProgress.Text = "Converting " + strsource + " into Text file is under process.";
Application.DoEvents();
object Source = strsource;
object Target = strtarget;
doc = newApp.Documents.Open(ref Source, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown);
if (doc.ReadOnlyRecommended == true)
return;
object format = Word.WdSaveFormat.wdFormatText;
newApp.ActiveDocument.SaveAs(ref Target, ref format,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown);
strTxtCounter = "OK";
}
catch (Exception ex)
{
strTxtCounter = "FAILED";
ZoniacLogger.Error(" Exception : " + ex.Message + " Stack Trace : " + ex.StackTrace);
}
finally
{
if (newApp != null)
{
newApp.Quit(ref Unknown, ref Unknown, ref Unknown);
newApp = null;
}
}
}
regards
kumaran