i try to open an Word Document with the name "Borecheck.docx"! But when i start my programm and get the error message: No overload for method "Open" takes "1" arguments (CA1501) Can someone help me?
This is my source code:
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);
}
}