From fba0624364c892b6a15f6f61db3927c56f415df6 Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 23 May 2012 13:03:24 +0000 Subject: [PATCH] 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 --- Greenshot/Destinations/WordDestination.cs | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Greenshot/Destinations/WordDestination.cs b/Greenshot/Destinations/WordDestination.cs index 5fc6e5f83..7b6b50aba 100644 --- a/Greenshot/Destinations/WordDestination.cs +++ b/Greenshot/Destinations/WordDestination.cs @@ -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 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;