今天准备制作一个标书生成软件,需要用到word的预览功能,效果如下:
1、下载并注册 dsoframer.ocx
注册:把这个文件放在C:WindowsSysWOW64目录下,去目录下找到cmd.exe,右键用管理员身份运行,然后 输入命令 regsvr32 c:/dsoframer.ocx就可以了。成功时如下:
这里其实复制到哪个目录下都可以的,重点是cmd要用管理员运行
2、新建vs项目,将ocx添加到工具箱中,
先右击选择“选择项”
在com组件中选择"dso Framer Control Object",确定
这样工具箱中就有这个工具了
3、将其拖动到窗体中,代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace mybs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//string file = Application.StartupPath + "\test.docx";
//axFramerControl1.Open(file);
}
private void button1_Click(object sender, EventArgs e)
{
string file = Application.StartupPath + "\test.docx";
axFramerControl1.Open(file);
}
private void button2_Click(object sender, EventArgs e)
{
axFramerControl1.Save();
}
}
}
