vba - Excel 2013 64位VBA语法错误 "Compile error: "应为: End of Statement"

标签 vba excel compiler-errors

我有以下代码,这给了我编译错误:“Inc”范围之后的代码主题行中出现“预期:语句结束”。

此代码是一个模块的一部分,该模块打开 MS Outlook 电子邮件并将数据表(从用户表单生成)中的特定单元格中的数据输入到电子邮件的主题字段中。

代码:

'This bit tells it where to send the email to, what the subject line is etc
    .to = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0d7d7f64636e687e7e5264636a6861647e684d746c656262236e62237866" rel="noreferrer noopener nofollow">[email protected]</a>"
    .CC = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d0a0a2b9beb3b5a3a38fb9beb7b5bcb9a3b590a9b1b8bfbffeb3bffea5bb" rel="noreferrer noopener nofollow">[email protected]</a>"
    .BCC = ""
    .Subject = "Inc" Range("H6").Value & " " & Range("G12").Value & " - " & Range("G14").Value & " " & Range("H8").Value
    .HTMLBody = RangetoHTML(rng)
    .Display

   End With
   On Error GoTo 0

这些信息足够吗?

最佳答案

你能检查一下是否是因为缺少“&”运算符

.Subject = "Inc"  Range("H6").Value & " " & Range("G12").Value & " - " & Range("G14").Value & " " & Range("H8").Value

应该是

.Subject = "Inc" & Range("H6").Value & " " & Range("G12").Value & " - " & Range("G14").Value & " " & Range("H8").Value

关于vba - Excel 2013 64位VBA语法错误 "Compile error: "应为: End of Statement",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37525129/

相关文章:

html - 如果条件满足,点击 HTMLelement

excel - 使用自定义类访问 OLEObject 事件

使用 SAS 引擎表现出色

vba - 循环 VBA 宏以打开文件夹中的文件、导入行,然后使用相对路径移动到另一个文件夹

c - 结构体数组错误

excel - 在 Excel 中用分号和空格分割文本字符串

vba - 为范围 VBA Excel 中的每个单元格设置偏移值

excel - 具有长路径名的 Excel 上的 Shell 命令不起作用

compiler-errors - 错误C2678 : binary '>>' : no operator found which takes a left-hand operand of type 'std::istream'

Java编译器错误谜题: "inner classes cannot have static declarations" - except for simple types