C # encapsulate common operations of Word

Source: Internet
Author: User

1 using System;
2 using System. Collections. Generic;
3 using System. Text;
4 using Microsoft. Office. Interop. Word;
5 using System. Diagnostics;
6 namespace OfficeManager
7 {
8 public class WordClass: IDisposable
9 {
10 # region Field
11 private _ Application m_WordApp = null;
12 private _ Document m_Document = null;
13 private object missing = System. Reflection. Missing. Value;
14 # endregion
15 # region constructor and destructor
16 public WordClass ()
17 {
18 m_WordApp = new ApplicationClass ();
19}
20 ~ WordClass ()
21 {
22 try
23 {
24 if (m_WordApp! = Null)
25 m_WordApp.Quit (ref missing, ref missing, ref missing );
26}
27 catch (Exception ex)
28 {
29 Debug. Write (ex. ToString ());
30}
31}
32 # endregion
33 # region attributes
34 public

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.