【问题标题】:System.Windows.Window.Activate() cannot implement Microsoft.Office.Interop.Word.Window.Activate() because it does not have the matching return type?System.Windows.Window.Activate() 无法实现 Microsoft.Office.Interop.Word.Window.Activate() 因为它没有匹配的返回类型?
【发布时间】:2014-03-10 13:15:04
【问题描述】:

//第1行发生错误:无法实现'Microsoft.Office.Interop.Word.Window.Activate()' //因为它没有匹配的返回类型'void'。 //有人帮我解决这个错误

public partial class Window1 : Window 
{
    public Window1()
    {
        InitializeComponent();
    }

    private void btnSelectWord_Click(object sender, RoutedEventArgs e)
    {
        // Initialize an OpenFileDialog 
        OpenFileDialog openFileDialog = new OpenFileDialog();


        // Set filter and RestoreDirectory 
        openFileDialog.RestoreDirectory = true;
        openFileDialog.Filter = "Word documents(*.doc;*.docx)|*.doc;*.docx";


        bool? result = openFileDialog.ShowDialog();
        if (result == true)
        {
            if (openFileDialog.FileName.Length > 0)
            {
                txbSelectedWordFile.Text = openFileDialog.FileName;
            }
        } 
    }

【问题讨论】:

  • 用一些文字来解释你的问题怎么样?哪一行不编译?
  • 公共部分类 Window1:Window

标签: c# .net wpf windows office-interop


【解决方案1】:

这个问题可能是由Microsoft.Office.Interop.WordSystem.Windows 这两个命名空间引起的。尝试以下方法来帮助编译器选择正确的类型:

public partial class Window1 : System.Windows.Window

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-09
    相关资源
    最近更新 更多