FIGURE 9.19
A folder with some Contact ID documents, for creating attachments.
In the LoadAttachmentsfunction listed as follows, declaring the rstAttachmentsvariable as
a Recordset2object (instead of a Recordset object) allows use of the new LoadFromFileand
SaveToFilemethods, which I use to load files into Attachment fields, or save files from
Attachment fields:
Public Function LoadAttachments()
On Error GoTo ErrorHandler
Dim intSpace As Integer
Dim strTest As String
Dim strSearch As String
strDocsPath = GetInputDocsPath()
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set fld = fso.GetFolder(strDocsPath)
Set dbs = CurrentDb
Set rstTable = dbs.OpenRecordset(“tblContacts”, dbOpenDynaset)
For Each fil In fld.Files
strFile = fil.Name
Debug.Print “File name: “ & strFile
Debug.Print “File type: “ & fil.Type
Check whether file name starts with ‘Contact ID’
If Left(strFile, 10) = “Contact ID” Then
Part II Writing VBA Code to Exchange Data between Office Components