使用VSTO向Word文档中添加数学公式
这是个极其简单的实例,用来向Word文档中添加一个数学汇总公式。
[csharp]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
using System.Diagnostics;
namespace VSTOInsertEquations
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Word.Application wdApplication = null;
Process[] pl = Process.GetProcessesByName("WINWORD.exe");
if (pl.Length > 0)
{
wdApplication = (Word.Application)System.Runtime.InteropServices
.Marshal.GetActiveObject("Word.Application");
}
else
{
wdApplication = new Word.Application();
}
if (wdApplication != null)
{
Word.Document newDocument = wdApplication.Documents.Add();
//一下代码添加了汇总公式
Word.Range wdFunctionR = wdApplication.Selection.OMaths
.Add(wdApplication.Selection.Range);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>