Retrying export to word if it fails... usually this is due to the error "COM object that has been separated from its underlying RCW cannot be used."

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1901 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-05-23 13:03:24 +00:00
commit fba0624364

View file

@ -119,7 +119,17 @@ namespace Greenshot.Destinations {
}
}
if (documentCaption != null) {
WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
try {
WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
} catch (Exception) {
try {
WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
} catch (Exception ex) {
LOG.Error(ex);
surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetFormattedString("destination_exportfailed", Description));
return false;
}
}
} else {
if (!manuallyInitiated) {
List<string> documents = WordExporter.GetWordDocuments();
@ -134,7 +144,17 @@ namespace Greenshot.Destinations {
return false;
}
}
WordExporter.InsertIntoNewDocument(tmpFile);
try {
WordExporter.InsertIntoNewDocument(tmpFile);
} catch(Exception) {
try {
WordExporter.InsertIntoNewDocument(tmpFile);
} catch (Exception ex) {
LOG.Error(ex);
surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetFormattedString("destination_exportfailed", Description));
return false;
}
}
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false;