From 6d298bfbfd25864954aad72b3e005fe5f09d53c2 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 7 Dec 2009 15:52:32 +0000 Subject: [PATCH] Added New Word Properties and Methods --- PROMS/LBWordLibrary/LBComObject.cs | 42 ++++++++++++++++++++++++ PROMS/LBWordLibrary/LBObjectExtension.cs | 39 +++++++++++++++++++--- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/PROMS/LBWordLibrary/LBComObject.cs b/PROMS/LBWordLibrary/LBComObject.cs index 6aec80b4..ba14534d 100644 --- a/PROMS/LBWordLibrary/LBComObject.cs +++ b/PROMS/LBWordLibrary/LBComObject.cs @@ -205,6 +205,10 @@ namespace LBWordLibrary get { return (GetProperty("Start") as int? ?? 0); } set { SetProperty("Start", value); } } + public LBInlineShapes InlineShapes + { + get { return new LBInlineShapes(GetProperty("InlineShapes")); } + } public void WholeStory() { InvokeMethod("WholeStory"); @@ -229,6 +233,14 @@ namespace LBWordLibrary { InvokeMethod("Copy"); } + public int EndKey() + { + return InvokeMethod("EndKey", Missing.Value, Missing.Value) as int? ?? 0; + } + public int EndKey(object Unit, object Extend) + { + return InvokeMethod("EndKey", Unit, Extend) as int? ?? 0; + } } public partial class LBDocumentClass : LBComObject { @@ -471,6 +483,21 @@ namespace LBWordLibrary wdInWordMail = 37, wdInClipboard = 38 } + public partial class LBInlineShapes : LBComObjectList /* Collection */ + { + public LBInlineShapes(Object item) + { + Item = item; + } + public LBInlineShape AddPicture(string FileName) + { + return new LBInlineShape(InvokeMethod("AddPicture", FileName, Missing.Value, Missing.Value, Missing.Value)); + } + public LBInlineShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range) + { + return new LBInlineShape(InvokeMethod("AddPicture", FileName, LinkToFile, SaveWithDocument, Range)); + } + } public enum LBWdExportFormat { wdExportFormatPDF = 17, @@ -635,6 +662,21 @@ namespace LBWordLibrary wdColorWhite = 16777215, wdColorAutomatic = -16777216 } + public partial class LBInlineShape : LBComObject + { + public LBInlineShape() { } + public LBInlineShape(Object item) : base(item) { } + public float Height + { + get { return (GetProperty("Height") as float? ?? 0); } + set { SetProperty("Height", value); } + } + public float Width + { + get { return (GetProperty("Width") as float? ?? 0); } + set { SetProperty("Width", value); } + } + } public partial class LBPages : LBComObjectList /* Collection */ { public LBPages(Object item) diff --git a/PROMS/LBWordLibrary/LBObjectExtension.cs b/PROMS/LBWordLibrary/LBObjectExtension.cs index f17021bf..d9fe9e11 100644 --- a/PROMS/LBWordLibrary/LBObjectExtension.cs +++ b/PROMS/LBWordLibrary/LBObjectExtension.cs @@ -75,9 +75,35 @@ namespace LBWordLibrary public string CreatePDF(string pdfFileName, bool openPDF) { pdfFileName = CreatePDF(pdfFileName); - if (openPDF) System.Diagnostics.Process.Start(pdfFileName); + if (openPDF) OpenPDF(pdfFileName); return pdfFileName; } + static List _AcrobatProcesses=new List(); + private static void OpenPDF(string pdfFileName) + { + _AcrobatProcesses.Add(System.Diagnostics.Process.Start(pdfFileName)); + } + public static void ClosePDFs() + { + foreach(System.Diagnostics.Process proc in _AcrobatProcesses) + if (!proc.HasExited) + KillAndWait(proc); + } + + + private static void KillAndWait(System.Diagnostics.Process proc) + { + Console.WriteLine("{0:s.ffff} Killing Adobe", DateTime.Now); + DateTime tStart = DateTime.Now; + proc.Kill(); + DateTime tEnd = DateTime.Now.AddMilliseconds(100); + while (DateTime.Now < tEnd) + { + Application.DoEvents(); + } + Console.WriteLine("{0:yyyy-MM-dd HH:mm:ss.ffff} {1:yyyy-MM-dd HH:mm:ss.ffff} {2}", DateTime.Now, proc.ExitTime + ,TimeSpan.FromTicks(proc.ExitTime.Ticks - tStart.Ticks).TotalMilliseconds); + } public string CreatePDF(string pdfFileName) { pdfFileName = AvailableFileName(pdfFileName); @@ -91,7 +117,7 @@ namespace LBWordLibrary public string CreatePDF2003FG(string pdfFileName, bool openPDF) { pdfFileName = CreatePDF2003FG(pdfFileName); - if (openPDF) System.Diagnostics.Process.Start(pdfFileName); + if (openPDF) OpenPDF(pdfFileName); return pdfFileName; } public string CreatePDF2003FG(string pdfFileName) @@ -120,7 +146,7 @@ namespace LBWordLibrary public string CreatePDF2003BG(string pdfFileName, bool openPDF) { pdfFileName = CreatePDF2003BG(pdfFileName); - if (openPDF) System.Diagnostics.Process.Start(pdfFileName); + if (openPDF) OpenPDF(pdfFileName); return pdfFileName; } public string CreatePDF2003BG(string pdfFileName) @@ -154,7 +180,7 @@ namespace LBWordLibrary public string CreatePDF2007(string pdfFileName, bool openPDF) { pdfFileName = CreatePDF2007(pdfFileName); - if (openPDF) System.Diagnostics.Process.Start(pdfFileName); + if (openPDF) OpenPDF(pdfFileName); return pdfFileName; } public string CreatePDF2007(string pdfFileName) @@ -252,5 +278,10 @@ namespace LBWordLibrary { return InvokeMethod("MoveEnd", Unit, Count) as int? ?? 0; } + public int EndKey(LBWdUnits Unit, bool Extend) + { + return InvokeMethod("EndKey", Unit, Extend) as int? ?? 0; + } + } }