Skip to content

Instantly share code, notes, and snippets.

@emreozguruoglu
Last active December 10, 2021 09:03
public dynamic OpenDocument(object fileName, object confirmConversions, object isReadOnly, object isAddToRecentFiles, object passwordDocument,
object passwordTemplate, object isRevert, object writePasswordDocument, object writePasswordTemplate, object openFormat,
object isVisible, object isOpenAndRepair, object docDirection, object isNoEncodingDialog, bool isScreenUpdating, bool isDisplayAlerts)
{
Word2.Application word = this.GetApp();
if (word != null)
{
object missing = System.Reflection.Missing.Value;
word.ScreenUpdating = isScreenUpdating;
if (isDisplayAlerts)
word.DisplayAlerts = WdAlertLevel.wdAlertsAll;
else
word.DisplayAlerts = WdAlertLevel.wdAlertsNone;
object oMissing = System.Reflection.Missing.Value;
//Document doc = word.Documents.Open(fileName, ref oMissing, isReadOnly, isAddToRecentFiles, passwordDocument, ref oMissing, ref oMissing,
//ref oMissing, ref oMissing, openFormat, ref oMissing, isVisible,
//ref oMissing, docDirection, ref oMissing, ref oMissing);
word.Documents.Open(FileName: fileName, ReadOnly: isReadOnly, AddToRecentFiles: isAddToRecentFiles, PasswordDocument: passwordDocument, PasswordTemplate: passwordTemplate, WritePasswordDocument: writePasswordDocument, WritePasswordTemplate: writePasswordTemplate, Format: openFormat, Encoding: missing, Visible: isVisible, DocumentDirection: docDirection);
}
return word;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment