update 20250113
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
|
||||
@@ -20,6 +21,7 @@ namespace OfficePrinter
|
||||
Microsoft.Office.Interop.Word.Document wordDocument = new Microsoft.Office.Interop.Word.Document();
|
||||
wordDocument = appWord.Documents.Open(filename);
|
||||
appWord.Visible = true;
|
||||
|
||||
wordDocument.PrintOut(
|
||||
OutputFileName: pdfname,
|
||||
PrintToFile: true);
|
||||
@@ -30,13 +32,15 @@ namespace OfficePrinter
|
||||
return;
|
||||
}
|
||||
|
||||
public void PrintInWord(string Filename, string printmacro)
|
||||
public void PrintInWord(string Filename, string printmacro, int OfficeSleep)
|
||||
{
|
||||
Application appWord = new Application();
|
||||
appWord.NormalTemplate.Saved = true;
|
||||
Microsoft.Office.Interop.Word.Document wordDocument = new Microsoft.Office.Interop.Word.Document();
|
||||
wordDocument = appWord.Documents.Open(Filename);
|
||||
Thread.Sleep(OfficeSleep);
|
||||
appWord.Visible = true;
|
||||
|
||||
if (printmacro == "") return;
|
||||
try
|
||||
{
|
||||
@@ -45,6 +49,7 @@ namespace OfficePrinter
|
||||
catch
|
||||
{
|
||||
}
|
||||
Thread.Sleep(OfficeSleep);
|
||||
wordDocument.Close();
|
||||
wordDocument = null;
|
||||
appWord.Quit(SaveChanges: false);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user