登录

子名称上的VBA“无效限定符”错误

内容来源于 Stack Overflow,遵循 CC BY-SA 4.0 许可协议进行翻译与使用。IT领域专用引擎提供翻译支持

腾讯云小微IT领域专用引擎提供翻译支持

原文
Stack Overflow用户 修改于2021-07-22
  • 该问题已被编辑
  • 提问者: Stack Overflow用户
  • 提问时间: 2021-07-22 17:43

我正处于创建Excel工作簿的早期阶段,它将允许您使用VBA生成和发送基于工作簿中客户端数据的Outlook电子邮件。但是,我在Sub声明行中得到了“无效限定符”的编译错误。

我的问题代码 (来源于此)

'Get file path and put it in the proper cell
Sub GetFilePath()
    Dim DialogBox As FileDialog
    Dim path As String
    Set DialogBox = Application.FileDialog(msoFileDialogFilePicker)
    DialogBox.Title = "Select quarterly report for " & Range("A" & ActiveCell.Row) & _
        " " & Range("B" & ActiveCell.Row)
    DialogBox.Filters.Clear
    DialogBox.Show
    If DialogBox.SelectedItems.Count = 1 Then
        path = DialogBox.SelectedItems(1)