【发布时间】:2018-10-18 07:10:33
【问题描述】:
我正在尝试保存启用 Word 宏的模板,然后通过电子邮件发送生成的文件,但无法打开保存(和发送)为 .docm 的文件。它抛出这个错误:
"We're sorry. We can't open B.docm because we found a problem with its contents"
我需要做些什么来“转换”文档吗?找不到任何关于它的信息,每个人似乎都同意我保存文档的方式很好。
这是我正在使用的代码:
Private Sub CommandButton1_Click()
'Save Document
Dim wdApp As Word.Application
Set wdApp = GetObject(, "Word.Application")
wdApp.ActiveDocument.SaveAs "H:\Word\B.docm"
'Send Email
Dim outlook As outlook.Application
Dim maiMessage As outlook.MailItem
Set outlook = New outlook.Application
Set maiMessage = outlook.CreateItem(olMailItem)
With maiMessage
.Subject = "Sent"
.Recipients.Add Name:="name@company.com"
.Attachments.Add Source:="H:\Word\B.docm"
.Send
End With
End Sub
更多信息:
- If I save the document by normal means (File > Save as > .docm), it works.
- If I save the document using the macro but with .docx extension, it also works.
【问题讨论】:
-
我们缺少一些背景信息...原始文件的文件扩展名是什么?它是如何在 Word 中打开的(如果有代码,请编辑问题并插入该代码)?它实际上包含宏吗?如果您尝试打开您保存的文件(未发送),它会正常打开吗?