update 20241201
This commit is contained in:
68
Client - Kopie/Backup/Klassen/clsWordEdit.cs
Normal file
68
Client - Kopie/Backup/Klassen/clsWordEdit.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace OnDoc.Klassen
|
||||
{
|
||||
public class clsWordEdit
|
||||
{
|
||||
public string connectstring { get;set; }
|
||||
public string filename { get; set; }
|
||||
public string dokumentid { get; set; }
|
||||
Microsoft.Office.Interop.Word.Application word;
|
||||
Document doc = null;
|
||||
|
||||
|
||||
public clsWordEdit(string connectstring, string filename, string dokumentid)
|
||||
{
|
||||
this.connectstring = connectstring;
|
||||
this.filename = filename;
|
||||
this.dokumentid = dokumentid;
|
||||
}
|
||||
|
||||
public bool Start_Application()
|
||||
{
|
||||
try
|
||||
{
|
||||
word = new Microsoft.Office.Interop.Word.Application();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Edit_Document()
|
||||
{
|
||||
Start_Application();
|
||||
doc = word.Documents.Open(filename);
|
||||
word.Visible= true;
|
||||
clsProcessWatch.AddToList(dokumentid, filename, "Word");
|
||||
bool isClosed = IsDocumentClosed(word, doc);
|
||||
}
|
||||
|
||||
public void Control_Word(string dokumentid, string filename, string application)
|
||||
{
|
||||
clsProcessWatch.AddToList(dokumentid, filename, application);
|
||||
}
|
||||
|
||||
static bool IsDocumentClosed(Application wordApp, Document doc)
|
||||
{
|
||||
// Check if the document is still listed in the Documents collection
|
||||
foreach (Document openDoc in wordApp.Documents)
|
||||
{
|
||||
if (openDoc.FullName == doc.FullName)
|
||||
{
|
||||
return false; // Document is still open
|
||||
}
|
||||
}
|
||||
return true; // Document is closed
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user