本文整理汇总了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");
}
}
示例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;
}
}
}