update 20240925
This commit is contained in:
145
OnDocOffice/Class1.cs
Normal file
145
OnDocOffice/Class1.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDocOffice
|
||||
{
|
||||
public class clsExcelEdit
|
||||
{
|
||||
public string connectstring { get; set; }
|
||||
public string filename { get; set; }
|
||||
public string dokumentid { get; set; }
|
||||
public
|
||||
Microsoft.Office.Interop.Excel.Application excel;
|
||||
Workbook workBook = null;
|
||||
|
||||
|
||||
public clsExcelEdit(string connectstring, string filename, string dokumentid)
|
||||
{
|
||||
this.connectstring = connectstring;
|
||||
this.filename = filename;
|
||||
this.dokumentid = dokumentid;
|
||||
|
||||
}
|
||||
|
||||
public bool Start_Application()
|
||||
{
|
||||
try
|
||||
{
|
||||
excel = new Microsoft.Office.Interop.Excel.Application();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Edit_Document()
|
||||
{
|
||||
Start_Application();
|
||||
workBook = excel.Workbooks.Open(filename);
|
||||
excel.Visible = true;
|
||||
//clsProcessWatch.AddToList(dokumentid, filename, "Word");
|
||||
bool isClosed = IsDocumentClosed(excel, workBook);
|
||||
workBook = null;
|
||||
excel = null;
|
||||
}
|
||||
|
||||
public void Control_Word(string dokumentid, string filename, string application)
|
||||
{
|
||||
//clsProcessWatch.AddToList(dokumentid, filename, application);
|
||||
}
|
||||
|
||||
static bool IsDocumentClosed(Microsoft.Office.Interop.Excel.Application excelApp, Workbook workBook)
|
||||
{
|
||||
// Check if the document is still listed in the Documents collection
|
||||
foreach (Workbook openDoc in excelApp.Workbooks)
|
||||
{
|
||||
if (openDoc.FullName == workBook.FullName)
|
||||
{
|
||||
return false; // Document is still open
|
||||
}
|
||||
}
|
||||
return true; // Document is closed
|
||||
}
|
||||
|
||||
public void run_macros()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 = 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);
|
||||
doc = null;
|
||||
word = null;
|
||||
}
|
||||
|
||||
public void Control_Word(string dokumentid, string filename, string application)
|
||||
{
|
||||
//clsProcessWatch.AddToList(dokumentid, filename, application);
|
||||
}
|
||||
|
||||
static bool IsDocumentClosed(Microsoft.Office.Interop.Word.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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user