diff --git a/PROMS/LBWordLibrary/LBObjectExtension.cs b/PROMS/LBWordLibrary/LBObjectExtension.cs index c8ce76ff..4596b445 100644 --- a/PROMS/LBWordLibrary/LBObjectExtension.cs +++ b/PROMS/LBWordLibrary/LBObjectExtension.cs @@ -10,6 +10,7 @@ namespace LBWordLibrary { public partial class LBApplicationClass : LBComObject { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// /// This gives the option of specifying Background = false to print in the foreground. /// @@ -41,13 +42,22 @@ namespace LBWordLibrary // This key only worked for Vista //RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Installer\Components\12B306B24E250DD428FC7016B6FB4BD8"); // This key works for Windows Vista and Windows 7 - RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\0E5C161912A2A6C4C93C76678926C56C"); - if (key != null) + try { - key.Close(); - return true; + RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\0E5C161912A2A6C4C93C76678926C56C"); + if (key != null) + { + key.Close(); + return true; + } + _MyLog.WarnFormat("MSWord2007 PDF Export Registry Key Missing"); + return false; + } + catch (Exception ex) + { + _MyLog.WarnFormat("MSWord2007 PDF Export Registry Key Failure {0} - {1}", ex.GetType().Name, ex.Message); + return false; } - return false; } } private bool CanCreatePDFFile(string pdfFileName) @@ -113,12 +123,15 @@ namespace LBWordLibrary public string CreatePDF(string pdfFileName) { pdfFileName = AvailableFileName(pdfFileName); - if (Convert.ToSingle(Version) > 12.0F) + if (((int)Convert.ToSingle(Version)) > 12) return CreatePDF2007(pdfFileName); - if (Convert.ToSingle(Version) == 12.0F && WordPDFExporterInstalled) + if (((int)Convert.ToSingle(Version)) == 12 && WordPDFExporterInstalled) return CreatePDF2007(pdfFileName); else if (VolianPDFInstalled) + { + _MyLog.WarnFormat("Using VolianPDFWriter - MSWord Version = '{0}'", Version); return CreatePDF2003BG(pdfFileName); + } else throw new Exception("No PDF Writer support installed for MS Word sections"); }