16,721
社区成员




document.all.FramerControl1.Open("C:\\Plain.txt",false, "Word.Document");
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;
private Word.Document bidDocument;
private Word.Application bidApplication;
private object missing = Type.Missing;
private void button1_Click(object sender, EventArgs e)
{
axframercontrol.CreateNew("Word.Document.8");
axframercontrol.Caption = "金康玉妍技术宝典修改版";
bidDocument = (Word.Document)axframercontrol.ActiveDocument;
//bidDocument.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
//bidDocument.ActiveWindow.DisplayRulers = false;
//bidDocument.ActiveWindow.DisplayScreenTips = false;
//bidDocument.ActiveWindow.DisplayHorizontalScrollBar = false;
//bidDocument.ActiveWindow.DisplayVerticalRuler = false;
//bidDocument.ActiveWindow.DisplayVerticalScrollBar = true;
bidApplication = bidDocument.Application;
if (double.Parse(bidApplication.Version) > 11)
axframercontrol.Menubar = false;
else
{
//禁用新建、打开、关闭菜单按钮
axframercontrol.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileNew, false);
axframercontrol.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileOpen, false);
axframercontrol.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileClose, false);
}
OpenWord(@"D:\代码.txt");
}
private void OpenWord(string fileName)
{//
object tempFile = fileName;
object tempPwd = "123456";
object none = "";
object format = Word.WdOpenFormat.wdOpenFormatAuto;
Word.ApplicationClass app = null;
try
{
app = new Microsoft.Office.Interop.Word.ApplicationClass();
Word.Document tempDoc = app.Documents.Open(ref tempFile, ref yes, ref no, ref no, ref tempPwd,
ref none, ref no, ref none, ref none, ref format, ref missing,
ref no, ref no, ref missing, ref missing, ref missing);
tempDoc.Password = "";
tempDoc.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdNoProtection, ref missing, ref tempPwd, ref missing, ref missing);
tempDoc.Save();
}
catch { }
finally
{
if (app != null)
app.Quit(ref yes, ref missing, ref missing);
}
bidDocument.Activate();
bidApplication.Selection.InsertFile(fileName, ref missing, ref missing, ref missing,
ref missing);
}