MS Access Lotus Notes附加文件夹中的多个文件

时间:2014-04-08 08:17:15

标签: vba ms-access lotus-notes

我需要弄清楚如何在MS Access vba中放置代码以附加所选文件夹中的所有文件。 现在我只能从一个特定的位置做一个:

PathLocation = "C:\Test\test.PDF"
If Not IsNull(PathLocation) Then
    txtAttach = PathLocation 
   Set objAttachment = objMailDocument.CREATERICHTEXTITEM("strFileAttachment")
   Set objEmbedObject = objAttachment.EMBEDOBJECT(1454, "", txtAttach, "strFileAttachment")
   End If

但我真正想要的是收集Test文件夹中的所有内容。

2 个答案:

答案 0 :(得分:2)

您需要Dir-语句来运行目录中的所有文件:

Dim PathLocation As String
Dim fileName As String
Dim filePath as String

PathLocation = "C:\Test\"
If Not IsNull(PathLocation) Then
  Set objAttachment = objMailDocument.CREATERICHTEXTITEM("strFileAttachment")
  fileName = Dir$(PathLocation & "*.*", 0)
  Do While fileName <> ""
    filePath = PathLocation & fileName
    Set objEmbedObject = objAttachment.EMBEDOBJECT(1454, "", filePath, "")
    fileName = Dir$()
  Loop
End If

通过例如只需PDF格式替换上面代码中的*.* *.pdf

答案 1 :(得分:0)

希望这应该有所帮助,最后还附有一个例子。

http://bytes.com/topic/access/insights/916710-select-file-folder-using-filedialog-object