简单操作Word类(1)

2005(C#),练习第一步整理出来的

ClssControlWord类:

using  System;
using  System.Collections.Generic;
using  System.Text;
using  System.IO;
using  Word;

namespace  WordControl
{
    
public class ClssControlWord
    
{
        
属性

        
构造函数

        
方法
    }
     
}

应用的练习代码:

 

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;

namespace  WordControl
{
    
public partial class Form1 : Form
    
{
        
private ClssControlWord ccw;
        
public Form1()
        
{
            InitializeComponent();
        }


        
private void button1_Click(object sender, EventArgs e)
        
{
            openFileDialog1.ShowDialog();
        }


        
private void btSearch_Click(object sender, EventArgs e)
        
{
            
if (openFileDialog1.ShowDialog() == DialogResult.OK)
                tbFilePath.Text 
= openFileDialog1.FileName;
        }


        
private void btOpen_Click(object sender, EventArgs e)
        
{
            ccw 
= new ClssControlWord(tbFilePath.Text);
            ccw.WordVisible 
= true;
            ccw.Open();
        }


        
private void btClose_Click(object sender, EventArgs e)
        
{
            ccw.Close();
        }


        
private void btNewWord_Click(object sender, EventArgs e)
        
{
            saveFileDialog1.Filter 
= "Word文件|*.doc";
            
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            
{
                ClssControlWord cc 
= new ClssControlWord();
                cc.CreateWord(saveFileDialog1.FileName);
                cc.Close();
            }

        }


        
private void btNewWordTemplate_Click(object sender, EventArgs e)
        
{
            saveFileDialog1.Filter 
= "Word模板文件|*.dot";
            
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            
{
                ClssControlWord cc 
= new ClssControlWord();
                cc.CreateWordTemplate(saveFileDialog1.FileName);
                cc.Close();
            }

        }


        
private void btDotToDoc_Click(object sender, EventArgs e)
        
{
            openFileDialog1.Filter 
= "Word模板文件|*.dot";
            
if (openFileDialog1.ShowDialog() == DialogResult.OK)
            
{

                saveFileDialog1.Filter 
= "Word文件|*.doc";
                
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                
{
                    ClssControlWord cc 
= new ClssControlWord();
                    cc.CreateFileFromDot(openFileDialog1.FileName, saveFileDialog1.FileName);
                    cc.Close();
                }

            }

        }


        
private void btSave_Click(object sender, EventArgs e)
        
{
            ccw.Save();
        }

    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值