Office操作

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Office控件只读

word:

Microsoft.Office.Interop.Word.Document wordDoc =

(Microsoft.Office.Interop.Word.Document)axFramerControl1.ActiveDocument;

Microsoft.Office.Interop.Word.Application wordApp = wordDoc.Application;

wordDoc.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields);

excel:

Microsoft.Office.Interop.Excel.Workbook excelDoc =

(Microsoft.Office.Interop.Excel.Workbook)axFramerControl1.ActiveDocument;

Microsoft.Office.Interop.Excel.Application excelApp = excelDoc.Application;

excelDoc.Protect(“123″, Type.Missing, Type.Missing);

Worksheet sh = (Worksheet)excelDoc.ActiveSheet;

sh.Protect(“123″, Type.Missing, Type.Missing, Type.Missing,

Type.Missing, Type.Missing, Type.Missing, Type.Missing,

Type.Missing, Type.Missing, Type.Missing, Type.Missing,

Type.Missing, true, Type.Missing, Type.Missing);

ppt自动预览:

Microsoft.Office.Interop.PowerPoint.Presentation pptDoc =

(Microsoft.Office.Interop.PowerPoint.Presentation)axFramerControl1.ActiveDocument; pptDoc.SlideShowSettings.RangeType =

Microsoft.Office.Interop.PowerPoint.PpSlideShowRangeType.ppShowSlideRange;

pptDoc.SlideShowSettings.ShowType = PpSlideShowType.ppShowTypeWindow2;

Microsoft.Office.Interop.PowerPoint.Application pptApp = pptDoc.Application;

pptDoc.Slides.Range(Type.Missing);

this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileClose, false);

this.axFramerControl1.ProtectDoc(1, 1, “pwd”);

SendKeys.Send(“{F5}”);

//另存为

Word

object Unknown = Type.Missing;

object myNothing = System.Reflection.Missing.Value;

Object myWordFormatDocument = Word.WdSaveFormat.wdFormatDocument;

Microsoft.Office.Interop.Word.Document word =

(Microsoft.Office.Interop.Word.Document)this.axFramerControl1.ActiveDocument;

word.SaveAs(ref myFileName, ref myWordFormatDocument, false,

"", true, "",

false, false, false, false, ref myNothing, ref

myNothing, ref myNothing,

ref myNothing, ref myNothing, ref

myNothing);

//

Excel

object missing = System.Reflection.Missing.Value;

Object myWordFormatDocument = Excel.XlFileFormat.xlWorkbookNormal;

Microsoft.Office.Interop.Excel.Workbook excel =

(Microsoft.Office.Interop.Excel.Workbook)this.axFramerControl1.ActiveDocument;

excel.SaveAs(myFileName,

Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);

PPT

PowPoint.PpSaveAsFileType formart = PowPoint.PpSaveAsFileType.ppSaveAsShow;

Microsoft.Office.Interop.PowerPoint.Presentation ppt =

(Microsoft.Office.Interop.PowerPoint.Presentation)this.axFramerControl1.ActiveDocument;

ppt.SaveAs(PathName, formart, Microsoft.Office.Core.MsoTriState.msoFalse);

相关文档
最新文档