【发布时间】:2015-09-11 13:13:53
【问题描述】:
我正在尝试获取一个代码,用于保存特定 Lotus Notes 文件夹的附件并将其保存到本地文件夹(不从 Lotus Notes 中删除电子邮件或附件)。但我不断收到错误消息:“对象或变量未设置” 我已经多次更改代码,但我只是不明白我做错了什么。我是 VBA 新手,不了解所有代码。我会非常感谢你的帮助。
谢谢!
Sub Save_Attachments()
Const stPath As String = "c:\Attachments"
Const EMBED_ATTACHMENT As Long = 1454
Const RICHTEXT As Long = 1
Dim noSession As Object
Dim noDatabase As Object
Dim noView As Object
Dim noDocument As Object
Dim noNextDocument As Object
Dim vaItem As Variant
Dim vaAttachment As Variant
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", " mail2\cbarrios.nsf")
Set noView = noDatabase.GetView("AAA")
Set noDocument = noView.GetFirstDocument
Do Until noDocument Is Nothing
Set noNextDocument = noView.GetNextDocument(noDocument)
If noDocument.HasEmbedded Then
Set vaItem = noDocument.GetFirstItem("Body")
If vaItem.Type = RICHTEXT Then
For Each vaAttachment In vaItem.EmbeddedObjects
If vaAttachment.Type = EMBED_ATTACHMENT Then
With vaAttachment
.ExtractFile stPath & vaAttachment.Name
End With
End If
Next vaAttachment
End If
End If
Set noDocument = noNextDocument
Loop
Set noNextDocument = Nothing
Set noDocument = Nothing
Set noView = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
End Sub
【问题讨论】:
-
这个错误出现在哪一行?它应该以黄色突出显示。