//第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;
}
}
}
答案 0 :(得分:2)
此问题可能由两个名称空间Microsoft.Office.Interop.Word
和System.Windows
引起。请尝试以下操作以帮助编译器选择正确的类型:
public partial class Window1 : System.Windows.Window