当前位置: 首页>>代码示例>>C#>>正文


C# Application.ChangeFileOpenDirectory方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Word.Application.ChangeFileOpenDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# Application.ChangeFileOpenDirectory方法的具体用法?C# Application.ChangeFileOpenDirectory怎么用?C# Application.ChangeFileOpenDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Word.Application的用法示例。


在下文中一共展示了Application.ChangeFileOpenDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareInWord

    public static void CompareInWord(string fullpath, string newFullpath, string saveName, string saveDir, string author, bool save = false) {
      Object missing = Type.Missing;
      try {
        var wordapp = new Microsoft.Office.Interop.Word.Application();
        try {
          var doc = wordapp.Documents.Open(fullpath, ReadOnly: true);
          doc.Compare(newFullpath, author ?? missing);
          doc.Close(WdSaveOptions.wdDoNotSaveChanges); // Close the original document
          var dialog = wordapp.Dialogs[WdWordDialog.wdDialogFileSummaryInfo];
          // Pre-set the save destination by setting the Title in the save dialog.
          // This must be done through reflection, since "dynamic" is only supported in .NET 4
          dialog.GetType().InvokeMember("Title", BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty,
                                        null, dialog, new object[] {saveName});
          dialog.Execute();
          wordapp.ChangeFileOpenDirectory(saveDir);
          if (!save) {
            wordapp.ActiveDocument.Saved = true;
          }

          wordapp.Visible = true;
          wordapp.Activate();

          // Simple hack to bring the window to the front.
          wordapp.ActiveWindow.WindowState = WdWindowState.wdWindowStateMinimize;
          wordapp.ActiveWindow.WindowState = WdWindowState.wdWindowStateMaximize;
        } catch (Exception ex) {
          Logger.LogException(ex);
          ShowMessageBox("Word could not open these documents. Please edit the file manually.", "Error");
          wordapp.Quit();
        }
      } catch (Exception ex) {
        Logger.LogException(ex);
        ShowMessageBox("Could not start Microsoft Word. Office 2003 or higher is required.", "Could not start Word");
      }
    }
开发者ID:SciGit,项目名称:scigit-client,代码行数:35,代码来源:Util.cs

示例2: CreateWord

 private void CreateWord() {
     lock(this) {
         if (msword == null) {
             msword = new Word.Application();
             msword.Visible = true;
             msword.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
             msword.ChangeFileOpenDirectory(Directory.GetCurrentDirectory());
             msword.AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable;
         }
     }
 }
开发者ID:lonjoy,项目名称:node-msoffice-pdf,代码行数:11,代码来源:office.cs


注:本文中的Microsoft.Office.Interop.Word.Application.ChangeFileOpenDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。