我试图打开一个名为"Borecheck.docx“的Word文档!但是当我启动我的程序并得到错误消息时:没有重载的方法"Open“需要"1”参数(CA1501),有人能帮我吗?
这是我的源代码:
using System.IO;
using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;
{
public partial class MainForm
{
void BoreCheckToolStripMenuItemClick(object sender, EventArgs e)
{
object wordObject = null;
try
{
wordObject = Marshal.GetActiveObject("Word.Application");
}
catch {}
Word.Application word = null;
bool wordInstanceCreated = false;
if (wordObject != null)
{
word = (Word.Application)wordObject;
}
else
{
wordInstanceCreated = true;
word = new Word.Application();
}
word.Visible = true;
string fileName = Path.Combine(Application.StartupPath, "Borecheck.docx");
word.Documents.Open(ref fileName);
}
}发布于 2015-02-18 12:43:28
信息很清楚。你不能传递正确数量的参数。来自Interop.Word Documents.Open为空
object oMissing = System.Reflection.Missing.Value;
Document doc = word.Documents.Open(filename, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);发布于 2015-02-18 12:43:02
好的,Documents.Open接受多个参数:
Document Open(
ref Object FileName,
ref Object ConfirmConversions,
ref Object ReadOnly,
ref Object AddToRecentFiles,
ref Object PasswordDocument,
ref Object PasswordTemplate,
ref Object Revert,
ref Object WritePasswordDocument,
ref Object WritePasswordTemplate,
ref Object Format,
ref Object Encoding,
ref Object Visible,
ref Object OpenAndRepair,
ref Object DocumentDirection,
ref Object NoEncodingDialog,
ref Object XMLTransform
)https://stackoverflow.com/questions/28583956
复制相似问题