请教高手:“Application是不明确的引用”时什么意思?
写一个WinForm打开Word的小程序,用按钮触发打开的事件
编译时报2个错:
1、“C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\OpenWord\Form1.cs(87): “Application”是不明确的引用
”
2、“C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\OpenWord\Form1.cs(95): 重载“Open”方法未获取“15”参数
”
请教高手如何解决,谢谢!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Word;//=Microsoft.Office.Interop.Word;
using System.Reflection;
namespace OpenWord
{
public class Form1 : System.Windows.Forms.Form
{
Word._Application oWapp;
Word._Document oDoc;
object oPath="c:\a.doc";//文件路径;
object misOpt = System.Reflection.Missing.Value;
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 48);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1()); //第1个报错
}
private void button1_Click(object sender, System.EventArgs e)
{
oWapp = new Word.Application();
oWapp.Visible = true;
oDoc = (Word._Document)(oWapp.Documents.Open(ref oPath,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt,ref misOpt)); //第2个报错
}
}
}