2

即,我在按钮处理程序中调用了以下代码段:

TextBox1.Text = Application.GetOpenFilename("All files (*.*),*.*", _
        1, "Open the Raw Data Files", , False)
If TextBox1.Text = "False" Then TextBox1.Text = ""

错误说:“编译器错误:找不到方法或数据成员”

提前致谢!

4

1 回答 1

7

Word中没有Application.GetOpenFilename

你需要FileDialog改用。这是一个简单的例子:

Private Sub CommandButton1_Click()
  Dim s As Variant
  Dim Res As Integer

  Dim dlgSaveAs As FileDialog
  Set dlgSaveAs = Application.FileDialog( _
                   FileDialogType:=msoFileDialogSaveAs)
  Res = dlgSaveAs.Show
  If Not Res = 0 Then
    For Each s In dlgSaveAs.SelectedItems  'There is only one
      MsgBox s
    Next
  End If
End Sub
于 2012-04-15T03:32:44.903 回答