コード例 #1
0
ファイル: Form1.cs プロジェクト: vese/Libraryo
        private void button7_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            object miss     = System.Reflection.Missing.Value;
            object path     = Application.StartupPath + "\\1.docx";
            object readOnly = true;

            Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
            string totaltext = "";

            for (int i = 0; i < docs.Paragraphs.Count; i++)
            {
                totaltext += " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString();
            }
            MessageBox.Show(totaltext);
            docs.Close();
            word.Quit();


            label1.Text = "";
            openFileDialog1.InitialDirectory = Application.StartupPath;
            openFileDialog1.FileName         = null;
            openFileDialog1.Filter           = "Файлы txt(*.txt)|*.txt|Файлы doc(*.doc)|*.doc*|Файлы fb2(*.fb2)|*.fb2|Файлы epub(*.epub)|*.epub";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                OpenBook = openFileDialog1.FileName;
                Process process = new Process();
                process.StartInfo.FileName  = @OpenBook;
                process.StartInfo.Arguments = "";
                process.Start();
            }
        }
コード例 #2
0
        private void FindAndReplace(Microsoft.Office.Interop.Word.Application doc, string findText, string replaceWithText)
        {
            if (replaceWithText.Length > 255)
            {
                FindAndReplace(doc, findText, findText + replaceWithText.Substring(255));
                replaceWithText = replaceWithText.Substring(0, 255);
            }

            //options
            object matchCase         = false;
            object matchWholeWord    = true;
            object matchWildCards    = false;
            object matchSoundsLike   = false;
            object matchAllWordForms = false;
            object forward           = true;
            object format            = false;
            object matchKashida      = false;
            object matchDiacritics   = false;
            object matchAlefHamza    = false;
            object matchControl      = false;
            object read_only         = false;
            object visible           = true;
            object replace           = 2;
            object wrap = 1;

            //execute find and replace
            doc.Selection.Find.Execute(findText, ref matchCase, ref matchWholeWord,
                                       ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap, ref format, replaceWithText, ref replace,
                                       ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl);
        }
コード例 #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            WordApplicaton template_word = new WordApplicaton();
            WordDocument   doc           = new WordDocument();

            object fileName = @"C:\templates\Anomaly scan.docx";
            // Define an object to pass to the API for missing parameters
            object missing = System.Type.Missing;

            doc = template_word.Documents.Open(ref fileName,
                                               ref missing, ref missing, ref missing, ref missing,
                                               ref missing, ref missing, ref missing, ref missing,
                                               ref missing, ref missing, ref missing, ref missing,
                                               ref missing, ref missing, ref missing);

            String        read = string.Empty;
            List <string> data = new List <string>();

            for (int i = 0; i < doc.Paragraphs.Count; i++)
            {
                string temp = doc.Paragraphs[i + 1].Range.Text.Trim();
                if (temp != string.Empty)
                {
                    data.Add(temp);
                }
            }
            //((_WordDocument)doc).Close();
            //((_WordApplication)word).Quit();
            // insert text at the current cursor location
            Microsoft.Office.Interop.Word.Application
                       word      = Globals.ThisAddIn.Application;
            Word.Range selection = word.Selection.Range;
            selection.Text = data.ToString();
        }
コード例 #4
0
        public Exsisting()
        {
            InitializeComponent();
            AxiomIRISRibbon.Utility.setTheme(this);

            _d = Globals.ThisAddIn.getData();

            app = Globals.ThisAddIn.Application;
        }
コード例 #5
0
        public void start()
        {
            this.word = ThisAddIn.The.Application;
            if (this.word == null)
            {
                this.word = new Microsoft.Office.Interop.Word.Application();
            }

            this.word.DocumentOpen   += new ApplicationEvents4_DocumentOpenEventHandler(documentOpen);
            this.word.WindowActivate += new ApplicationEvents4_WindowActivateEventHandler(windowActivate);
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            // format text
            StringBuilder buffer = new StringBuilder();

            buffer.AppendLine("teststr");
            // insert text at the current cursor location
            Microsoft.Office.Interop.Word.Application
                       word      = Globals.ThisAddIn.Application;
            Word.Range selection = word.Selection.Range;
            selection.Text = buffer.ToString();
        }
コード例 #7
0
        public void quit()
        {
            if (this.word == null)
            {
                return;
            }

            try
            {
                //Now use the Quit method to cleanup.
                //The Quit event will fire because saveChanges is set to wdDoNotSaveChanges.
                //If saveChanges were changed to wdSaveChanges, the Quit event will not fire.
                object saveChanges    = WdSaveOptions.wdDoNotSaveChanges;
                object originalFormat = Missing.Value;
                object routeDocument  = Missing.Value;
                word.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
                Thread.Sleep(2000);
            }
            catch { }
            this.word = null;
        }
コード例 #8
0
ファイル: ThisAddIn.cs プロジェクト: dwickeroth/covise
        public void start()
        {
            this.word = ThisAddIn.The.Application;
            if (this.word == null)
            {
                this.word = new Microsoft.Office.Interop.Word.Application();
            }

            this.word.DocumentOpen += new ApplicationEvents4_DocumentOpenEventHandler(documentOpen);
            this.word.WindowActivate += new ApplicationEvents4_WindowActivateEventHandler(windowActivate);
        }
コード例 #9
0
ファイル: ThisAddIn.cs プロジェクト: dwickeroth/covise
        public void quit()
        {
            if (this.word == null) return;

            try
            {
                //Now use the Quit method to cleanup.
                //The Quit event will fire because saveChanges is set to wdDoNotSaveChanges.
                //If saveChanges were changed to wdSaveChanges, the Quit event will not fire.
                object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
                object originalFormat = Missing.Value;
                object routeDocument = Missing.Value;
                word.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
                Thread.Sleep(2000);
            }
            catch { }
            this.word = null;
        }