using System; using System.Collections.Generic; using System.Text; namespace Baza_Reklam { class WordHandler { Object oMissing = System.Reflection.Missing.Value; Object oTrue = true; Object oFalse = false; Word.Application oWord; Word.Document oWordDoc; public WordHandler() { oWord = new Word.Application(); } public void openFile(string filename){ Object oPlik = filename; oWordDoc = oWord.Documents.Open(ref oPlik, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oTrue); } public void setWordVisible() { if (!oWord.Visible) oWord.Visible = true; } public void findAndReplace(string _strFind, string _strReplace) { Object oFindText = _strFind; Object oReplaceText = _strReplace; Object oReplace = (Object)Word.WdReplace.wdReplaceAll; bool _boolToF = oWordDoc.Content.Find.Execute(ref oFindText, ref oFalse, ref oFalse, ref oFalse, ref oFalse, ref oFalse, ref oFalse, ref oMissing, ref oFalse, ref oReplaceText, ref oReplace, ref oFalse, ref oFalse, ref oFalse, ref oFalse); } public void saveAs(string filename) { Object oFileNameAs = filename; oWordDoc.SaveAs(ref oFileNameAs, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); } } }