
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemText;
using SystemWindowsForms;
using MicrosoftOfficeInteropWord; 数据挖掘研究院
namespace WordTest
{
public partial class Form1 : Form
{
object strFileName;
Object Nothing;
MicrosoftOfficeInteropWordApplication myWordApp = new MicrosoftOfficeInteropWordApplicationClass();
Document myWordDoc;
string strContent = ""; 数据挖掘研究院
public Form1()
{
InitializeComponent();
}
数据挖掘研究院
private void button1_Click(object sender, EventArgs e)
{
createWord();
//openWord();
} 数据挖掘研究院
private void createWord()
{
strFileName = SystemWindowsFormsApplicationStartupPath + "testdoc";
if (SystemIOFileExists((string)strFileName))
SystemIOFileDelete((string)strFileName);
Object Nothing = SystemReflectionMissingValue;
myWordDoc = myWordAppDocumentsAdd(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
数据挖掘研究院
#region 将数据库中读取得数据写入到word文件中 数据挖掘研究院
strContent = "你好 ";
myWordDocParagraphsLastRangeText = strContent;
数据挖掘实验室
strContent = "这是测试程序";
myWordDocParagraphsLastRangeText = strContent; 数据挖掘研究院
#endregion 数据挖掘研究院
//将WordDoc文档对象的内容保存为DOC文档
myWordDocSaveAs(ref strFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//关闭WordDoc文档对象
myWordDocClose(ref Nothing, ref Nothing, ref Nothing);
//关闭WordApp组件对象
myWordAppQuit(ref Nothing, ref Nothing, ref Nothing);
数据挖掘研究院
thisrichTextBox1Text = strFileName + " " + "创建成功";
数据挖掘实验室
}
private void openWord()
{
fontDialog1ShowDialog();
SystemDrawingFont font = fontDialog1Font;
object filepath = "D:\aspdocx";
object oMissing = SystemReflectionMissingValue;
myWordDoc = myWordAppDocumentsOpen(ref filepath, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); 数据挖掘研究院
myWordDocContentFontSize = fontSize;
myWordDocContentFontName = fontName;
myWordDocSave();
richTextBox1Text = myWordDocContentText;
myWordDocClose(ref oMissing, ref oMissing, ref oMissing);
myWordAppQuit(ref oMissing, ref oMissing, ref oMissing);
} 数据挖掘研究院
}
数据挖掘研究院
>word文档多人编辑进不去解决方法如下:
1、打开想要多人编辑的word文档。
2、单击右上角的共享按钮和保存到云按钮。
3、将文档上传到服务器上后等待链接成功。
4、在通讯录中选择想要协同编辑的成员即可。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)