2

我想在我的应用程序中打开几个文档,但是这样做时,Word 总是打开主窗口。我怎样才能防止这种情况发生?

我已经将应用程序和文档的可见性设置为false,但是当我启动程序时它仍然打开。

private static readonly Application word = new Application();

[...]

FileInfo fileInfo = (FileInfo)file;

object filename = fileInfo.FullName;
object confirmConversion = false;
object readOnly = true;
object visible = false;
object skipEncodingDialog = true;
object save = false;

word.Visible = false;

Document srcDoc = word.Documents.Open(ref filename, ref confirmConversion, ref readOnly, ref missing,
    ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref visible,
    ref missing, ref missing, ref skipEncodingDialog, ref missing);
4

1 回答 1

3

应用程序字=新应用程序();代表一个单词窗口。

private void OpenWord(string path)
{
Application word = new Application();
FileInfo fileInfo = (FileInfo)file;

object filename = fileInfo.FullName;
object confirmConversion = false;
object readOnly = true;
object visible = false;
object skipEncodingDialog = true;
object save = false;

word.Visible = false;

Document srcDoc = word.Documents.Open(ref path, ref confirmConversion, ref readOnly, ref missing,
    ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref visible,
    ref missing, ref missing, ref skipEncodingDialog, ref missing);
}
于 2012-07-24T12:28:57.903 回答