You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.1 KiB
78 lines
2.1 KiB
using Microsoft.Office.Interop.Word;
|
|
using OnDoc.UIControls.Administrator;
|
|
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; }
|
|
public
|
|
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 = Interaction.CreateObject("Word.Application")
|
|
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
|
|
}
|
|
|
|
public void run_macros()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|