update 20250119
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
|
||||
|
||||
|
||||
namespace OfficePrinter
|
||||
@@ -32,8 +33,9 @@ namespace OfficePrinter
|
||||
return;
|
||||
}
|
||||
|
||||
public void PrintInWord(string Filename, string printmacro, int OfficeSleep)
|
||||
public string PrintInWord(string Filename, string printmacro, int OfficeSleep)
|
||||
{
|
||||
string error = "";
|
||||
Application appWord = new Application();
|
||||
appWord.NormalTemplate.Saved = true;
|
||||
Microsoft.Office.Interop.Word.Document wordDocument = new Microsoft.Office.Interop.Word.Document();
|
||||
@@ -41,20 +43,20 @@ namespace OfficePrinter
|
||||
Thread.Sleep(OfficeSleep);
|
||||
appWord.Visible = true;
|
||||
|
||||
if (printmacro == "") return;
|
||||
if (printmacro == "") return "";
|
||||
try
|
||||
{
|
||||
appWord.Run(printmacro);
|
||||
}
|
||||
catch
|
||||
{
|
||||
catch (Exception e) {
|
||||
error = e.Message.ToString()+" / "+printmacro;
|
||||
}
|
||||
Thread.Sleep(OfficeSleep);
|
||||
wordDocument.Close();
|
||||
wordDocument = null;
|
||||
appWord.Quit(SaveChanges: false);
|
||||
appWord = null;
|
||||
return;
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user