c++word常用操作.doc_第1页
c++word常用操作.doc_第2页
c++word常用操作.doc_第3页
c++word常用操作.doc_第4页
c++word常用操作.doc_第5页
已阅读5页,还剩37页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

c#word常用操作 收藏 public partial class ThisDocument private Office.CommandBarPopup MenuBarItem; / Arbitrary Tag value for new menu item. private const string MENU_TAG = DEMO_CODE; #region Manipulate Menubar private void InitMenuBarItems() / set up Command Bars Office.CommandBar MainMenuBar; try MainMenuBar = ThisApplication.CommandBarsMenu Bar; / Attempt to find the existing menu bar item. this.MenuBarItem = (Office.CommandBarPopup)MainMenuBar.FindControl(Office.MsoControlType.msoControlPopup, missing, MENU_TAG, missing, missing); if (this.MenuBarItem = null) this.MenuBarItem = (Office.CommandBarPopup)MainMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, missing); this.MenuBarItem.Caption = 演示(&D); this.MenuBarItem.Visible = true; this.MenuBarItem.Tag = MENU_TAG; / Add all the sub menu items. /HookUpMenuItem(重置文档内容,ResetDemoText); /HookUpMenuItem(新建窗口并平铺,CreateNewWindowAndTile, true); /HookUpMenuItem(设置程序标题, SetApplicationCaption); /HookUpMenuItem(切换状态栏显示, ToggleStatusBar); /HookUpMenuItem(显示C盘的所有DOC文件, ListAllDocFilesOnC); /HookUpMenuItem(更改用户名, ChangeUserName); /HookUpMenuItem(拼写检查, SpellCheckString); /HookUpMenuItem(显示“关于”对话框, DisplayHelpAbout); /HookUpMenuItem(移动并调整窗口, MoveAndResizeWindow); /HookUpMenuItem(启动邮件向导, LaunchFaxWizard); /HookUpMenuItem(显示“新建”对话框, DisplayFileNewDialog); /HookUpMenuItem(显示“用户”信息对话框, DisplayUserInfoDialog); /HookUpMenuItem(保存“用户”信息对话框的更改, DisplayExecuteDialog); /HookUpMenuItem(隐藏“页面设置”对话框, HiddenPageSetupDialog); /HookUpMenuItem(保存所有未保存的文档, SaveUnsavedDocuments); /HookUpMenuItem(显示所选内容的类型, ShowSelectionType); /HookUpMenuItem(在插入点插入文本, InsertTextAtSelection); /HookUpMenuItem(选择句子, SelectSentence); /HookUpMenuItem(格式化区域并取消, FormatRangeAndUndo); /HookUpMenuItem(操作区域中的文本, ManipulateRangeText); /HookUpMenuItem(创建书签, CreateBookmarks); /HookUpMenuItem(显示所有书签, ListBookmarks); /HookUpMenuItem(显示书签文本, BookmarkText); /HookUpMenuItem(在所选内容中查找, FindInSelection); /HookUpMenuItem(在区域中查找, FindInRange); /HookUpMenuItem(循环查找并格式化,FindInLoopAndFormat); /HookUpMenuItem(替换, SearchAndReplace); /HookUpMenuItem(替换并恢复, ReplaceAndRestoreSelection); /HookUpMenuItem(切换“预览”对话框, TogglePrintPreview); /HookUpMenuItem(打印文档, PrintOutDoc); /HookUpMenuItem(新建表格, CreateTable); /HookUpMenuItem(添加表格行、列, AddRowAndCol); /HookUpMenuItem(更新书签文字, BookmarkText); /HookUpMenuItem(检查CAPSLOCK状态, CapsLockOn); /HookUpMenuItem(更改应用程序可视, ChangeApplicationVisible); /HookUpMenuItem(更改用户姓名, ChangeUserName); /HookUpMenuItem(关闭所有文档, CloseAllDocuments); /HookUpMenuItem(关闭所有文档并保存, CloseAndSave); /HookUpMenuItem(关闭单个文档并保存, CloseSingleDocumentAndSave); /HookUpMenuItem(关闭单个文档不保存, CloseSingleDocumentWithoutSave); /HookUpMenuItem(关闭并不保存, CloseWithoutSave); /HookUpMenuItem(折叠区域, CollapseRange); /HookUpMenuItem(计算区域字符数, CountRangeCharacters); /HookUpMenuItem(创建书签, CreateBookmarks); /HookUpMenuItem(新建文档, CreateNewDocument); /HookUpMenuItem(新建窗口并平铺, CreateNewWindowAndTile); /HookUpMenuItem(新建表格, CreateTable); /HookUpMenuItem(新建表格完整版, CreateTableFull); HookUpMenuItem(AddRowAndCol, AddRowAndCol); HookUpMenuItem(BookmarkText, BookmarkText); HookUpMenuItem(CapsLockOn, CapsLockOn); HookUpMenuItem(ChangeApplicationVisible, ChangeApplicationVisible); HookUpMenuItem(ChangeUserName, ChangeUserName); HookUpMenuItem(CloseAllDocuments, CloseAllDocuments); HookUpMenuItem(CloseAllDocumentsAndSave, CloseAllDocumentsAndSave); HookUpMenuItem(CloseSingleDocumentAndSave, CloseSingleDocumentAndSave); HookUpMenuItem(CloseSingleDocumentWithoutSave, CloseSingleDocumentWithoutSave); HookUpMenuItem(CloseAllDocumentsWithoutSave, CloseAllDocumentsWithoutSave); HookUpMenuItem(CollapseRange, CollapseRange); HookUpMenuItem(CountRangeCharacters, CountRangeCharacters); HookUpMenuItem(CreateBookmarks, CreateBookmarks); HookUpMenuItem(CreateNewDocument, CreateNewDocument); HookUpMenuItem(CreateNewWindowAndTile, CreateNewWindowAndTile); HookUpMenuItem(CreateTable, CreateTable); HookUpMenuItem(CreateTableFull, CreateTableFull); HookUpMenuItem(CriteriaSpecify, CriteriaSpecify); HookUpMenuItem(DisplayAlerts, DisplayAlerts); HookUpMenuItem(DisplayApplicationPath, DisplayApplicationPath); HookUpMenuItem(DisplayExecuteDialog, DisplayExecuteDialog); HookUpMenuItem(DisplayFileNewDialog, DisplayFileNewDialog); HookUpMenuItem(DisplayHelpAbout, DisplayHelpAbout); HookUpMenuItem(DisplaySpellCheckDialog, DisplaySpellCheckDialog); HookUpMenuItem(DisplayUserInfoDialog, DisplayUserInfoDialog); HookUpMenuItem(DistrubeColumns, DistrubeColumns); HookUpMenuItem(FindInLoopAndFormat, FindInLoopAndFormat); HookUpMenuItem(FindInRange, FindInRange); HookUpMenuItem(FindInSelection, FindInSelection); HookUpMenuItem(FinishInitialization, FinishInitialization); HookUpMenuItem(FormatRangeAndUndo, FormatRangeAndUndo); HookUpMenuItem(HiddenPageSetupDialog, HiddenPageSetupDialog); HookUpMenuItem(Initialize, Initialize); HookUpMenuItem(InitializeDataBindings, InitializeDataBindings); HookUpMenuItem(InsertBeforeAfterBookmark, InsertBeforeAfterBookmark); HookUpMenuItem(InsertText, InsertText); HookUpMenuItem(InsertTextAtSelection, InsertTextAtSelection); HookUpMenuItem(LaunchFaxWizard, LaunchFaxWizard); HookUpMenuItem(ListAllDocFilesOnC, ListAllDocFilesOnC); HookUpMenuItem(ListBookmarks, ListBookmarks); HookUpMenuItem(ManipulateCell, ManipulateCell); HookUpMenuItem(ManipulateRangeText, ManipulateRangeText); HookUpMenuItem(ManipulateTable, ManipulateTable); HookUpMenuItem(MoveMethod, MoveMethod); HookUpMenuItem(MoveAndResizeWindow, MoveAndResizeWindow); HookUpMenuItem(MoveDownMethod, MoveDownMethod); HookUpMenuItem(MoveStart, MoveStart); HookUpMenuItem(MoveUpMethod, MoveUpMethod); HookUpMenuItem(OnShutdown, OnShutdown); HookUpMenuItem(OpenDocument, OpenDocument); HookUpMenuItem(PrintOutDoc, PrintOutDoc); HookUpMenuItem(PrintOutDocument, PrintOutDocument); HookUpMenuItem(PrintPreviewDocument, PrintPreviewDocument); HookUpMenuItem(QuitAutoSave, QuitAutoSave); HookUpMenuItem(QuitPromptToSave, QuitPromptToSave); HookUpMenuItem(QuitWithoutSave, QuitWithoutSave); HookUpMenuItem(ReplaceAndRestoreSelection, ReplaceAndRestoreSelection); HookUpMenuItem(ReplaceBookmarkText, ReplaceBookmarkText); HookUpMenuItem(ReplaceText, ReplaceText); HookUpMenuItem(ResetDemoText, ResetDemoText); HookUpMenuItem(RetrieveStartEnd, RetrieveStartEnd); HookUpMenuItem(SaveAllDocuments, SaveAllDocuments); HookUpMenuItem(SaveAsDocument, SaveAsDocument); HookUpMenuItem(SaveDocumentWithoutPrompt, SaveDocumentWithoutPrompt); HookUpMenuItem(SaveSingleDocument, SaveSingleDocument); HookUpMenuItem(SaveSpecifiedDocument, SaveSpecifiedDocument); HookUpMenuItem(SaveUnsavedDocuments, SaveUnsavedDocuments); HookUpMenuItem(SearchAndReplace, SearchAndReplace); HookUpMenuItem(SelectAllContentAsRange, SelectAllContentAsRange); HookUpMenuItem(SelectRange, SelectRange); HookUpMenuItem(SelectSentence, SelectSentence); HookUpMenuItem(SelectSentenceDirectly, SelectSentenceDirectly); HookUpMenuItem(SelectWholeRange, SelectWholeRange); HookUpMenuItem(SendArrowKeyLeft, SendArrowKeyLeft); HookUpMenuItem(SendArrowKeyRight, SendArrowKeyRight); HookUpMenuItem(SendHomeKeyBegin, SendHomeKeyBegin); HookUpMenuItem(SendHomeKeyEnd, SendHomeKeyEnd); HookUpMenuItem(SetApplicationCaption, SetApplicationCaption); HookUpMenuItem(SetRange, SetRange); HookUpMenuItem(SetVariousApplicationOptions, SetVariousApplicationOptions); HookUpMenuItem(ShowSelectionType, ShowSelectionType); HookUpMenuItem(SpellCheckString, SpellCheckString); HookUpMenuItem(SwapParagraph, SwapParagraph); HookUpMenuItem(TogglePrintPreview, TogglePrintPreview); HookUpMenuItem(ToggleStatusBar, ToggleStatusBar); catch (Exception ex) MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); private void HookUpMenuItem(string strCaption,string strProcToCall) HookUpMenuItem(strCaption ,strProcToCall , false); private void HookUpMenuItem(string strCaption, string strProcToCall, bool BeginNewGroup) Office.CommandBarButton cbb = CreateButton(strCaption ); cbb.Tag = strProcToCall; cbb.BeginGroup = BeginNewGroup; cbb.Click += new Office._CommandBarButtonEvents_ClickEventHandler(MenuItem_Click); private void MenuItem_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault) / Use Reflection, given the name of the procedure, to call the / procedure whose name is stored in the buttons Tag property. / Its ugly, but it works. try Type t = typeof(ThisDocument ); MethodInfo m = t.GetMethod(Ctrl.Tag); m.Invoke(this, null); catch (Exception ex) MessageBox.Show(ex.Message); #endregion private Office.CommandBarButton CreateButton(string Caption) Office.CommandBarButton cbb = null; try cbb = (Office.CommandBarButton)this.MenuBarItem.Controls.Add(Office.MsoControlType.msoControlButton, missing,missing, missing, true); cbb.Caption = Caption; cbb.Visible = true; catch (Exception ex) MessageBox.Show(ex.Message,ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); return cbb; private void RemoveDemoMenuItem() try Office.CommandBar MainMenuBar = ThisApplication.CommandBarsMenu Bar; / Need to locate the custom menu item again. this.MenuBarItem = (Office.CommandBarPopup)MainMenuBar.FindControl( Office.MsoControlType.msoControlPopup, missing, MENU_TAG, missing, missing); this.MenuBarItem.Delete(missing); catch / if theres an error, dont complain. public void ResetDemoText() try string docText = Visual Studio Tools for the Microsoft Office System+Environment.NewLine+在创建收集、分析、处理或提供信息的业务应用程序时,可以利用 Microsoft Office 2003 的强大功能。通过将功能丰富的客户端应用程序集成到业务解决方案中,不但可以使用每个桌面都提供的功能,而且最终用户也可以使用熟悉的工作环境。 + Environment.NewLine + Microsoft Visual Studio 2005 Tools for the Microsoft Office System 可以帮助您利用 Microsoft .NET Framework 2.0 版 中的效率增强,使用 Visual Basic 和 Visual C# 扩展 Microsoft Office Word 2003、Microsoft Office Excel 2003 和 Microsoft Office Outlook 2003。工具中包含新的 Visual Studio 项目,用于帮助您为 Office 应用程序创建自定义功能。 + Environment.NewLine + 有关 Office 可编程技术的最新信息,请参见 Microsoft Office 开发人员中心 (/china/office/default.mspx)。该站点包含一些链接,指向技术文章、代码示例、下载、社区信息、支持以及有关生成自定义 Office 解决方案的其他 MSDN 文档。 + Environment.NewLine + 本节内容: + Environment.NewLine + 入门 (Visual Studio Tools for Office) + Environment.NewLine + 提供一些链接,指向有关安装 Visual Studio Tools for Office、如何开始创建解决方案以及从早期版本以来发生了哪些更改的信息。 + Environment.NewLine + Visual Studio Tools for Office 解决方案的结构 + Environment.NewLine + 提供一些链接,指向有关 Visual Studio Tools for Office 解决方案如何工作的信息(包括有关自定义文档属性、数据模型以及运行时存储控件的信息)。 + Environment.NewLine + 升级 Office 解决方案 + Environment.NewLine + 包含一些链接,指向有关升级过程、升级项目中必须做的更改以及 Microsoft .NET Framework 并行安装的注意事项的信息。 + Environment.NewLine + 在 Visual Studio 中创建 Office 解决方案 + Environment.NewLine + 提供一些链接,指向有关创建 Office 解决方案以及程序集在解决方案中的作用的信息。 + Environment.NewLine + 编写 Word 和 Excel 应用程序 + Environment.NewLine + 提供一些链接,指向有关在 Word 和 Excel 解决方案中使用托管代码的信息(包括自定义 Office 用户界面、在 Office 文档中使用控件和使用操作窗格)。 + Environment.NewLine + 使用 Office 对象模型实现应用程序自动化 + Environment.NewLine + 提供一些链接,指向有关使用托管代码使 Office 解决方案自动化的信息。 + Environment.NewLine + Office 解决方案中的数据 + Environment.NewLine + 提供一些链接,指向解释数据如何在 Office 解决方案中工作的主题(包括有关面向架构的编程、数据缓存和服务器端数据访问的信息)。 + Environment.NewLine + 生成并调试 Office 项目 + Environment.NewLine + 列出解释生成和调试 Visual Studio Tools for Office 项目和 Visual Studio 中其他类型的项目(如 Windows 窗体)之间的几处不同的主题。 + Environment.NewLine + Office 解决方案的疑难解答 + Environment.NewLine + 提供一些链接,指向包含关于解决在使用 Visual Studio Tools for Office 创建 Office 解决方案时可能遇到的常见问题的提示的主题。 + Environment.NewLine + Office 解决方案中的安全性 + Environment.NewLine + 包含解释 Visual Studio Tools for Office 解决方案如何合并 Microsoft .NET Framework 提供的安全功能的主题。 + Environment.NewLine + 部署 Office 解决方案 + Environment.NewLine + 提供一些链接,指向有关如何使 Office 解决方案可供用户使用以及在选择部署方法和设置安全性时要考虑的主要问题的信息。 + Environment.NewLine + Visual Studio Tools for Office 中的项目扩展性 + Environment.NewLine + 列出提供有关 Visual Studio Tools for Office 项目中的自动化和扩展性的信息的主题,这些信息可以用来使集成开发环境中的任务自动化以及扩展项目类型和项目项。 + nr + Environment.NewLine + Office 开发示例和演练 + Environment.NewLine + 提供一些链接,指向示例应用程序和提供关于执行常见任务的分步指导的主题。 ; Object start = 0; Object end = this.Characters.Count; Object styleName = lorem; Word.Range rng = this.Range(ref start, ref end); rng.Text = docText; rng.set_Style(ref styleName); catch / do nothing private void ThisDocument_Startup(object sender, System.EventArgs e) InitMenuBarItems(); ResetDemoText(); private void ThisDocument_Shutdown(object sender, System.EventArgs e) RemoveDemoMenuItem(); #region ActiveWindow /ActiveWindow: Returns a Window object that represents the window that has the focus. This property allows you to work with whatever window has the focus. The sample code below creates a new window based on the current document and then uses the Arrange method of a Window object to tile the two windows. Note that the Arrange method uses the WdArrangeStyle.wdTiled enumerated value. (The sample application does not create a new window based on the current document: it instead creates a new document. Because the sample uses an actions pane to provide its demonstration menu, you cannot create a new window based on the current document. That feature is unavailable when using an actions pane. Therefore, the sample simply creates a new document to demonstrate the tiling feature.) public void CreateNewWindowAn

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论