Solved Export attachments to Folder - Not putting attachments in Folders

It should save whatever files are in your "attachment field". The default file type selection is "*.*".
The demo constrained the file types to be moved to "*.*g" ---which in the demo is for *.jpg and *.png.
If you have a test database with an attachment field, assign some pdf or ppt or other file types to that field and test before doing any changes in your production/operational database. Let us your progress.

If your requirement is for a different directory/folder structure pattern, then that logic will have to be tested and adjusted separately.
Good luck with your project.


My friend jdraw,

Already i tested with word, excel files but it does not work, even cannot create the customer folder if you have these type of format attachments..!! Please, have a look into your example..

In any case, if we can fix this problem this example should help i think many developers...

Thanks once again
 
Post a copy of your sample database and I'll look into it.
it does not work doesn't help anyone. Show your code and effort if you want focused help.

Based on your comments, I went back to the demo database and added a number of attachments to record id 3 "Ethyl" as shown in the graphic
revisedAttachmentsForDemo.PNG


Also, I modified the test routine
Code:
'routine to test the saveattachmentsTest function.
Sub testMakePath()
    Dim testpath As String
  'testpath = "C:\Jack\TestJ\FromAttachments"
  'Debug.Print SaveAttachmentsTest(testpath, "*.*g")
testpath = "C:\Jack\TestJ\FromAttachments\March10"  '<---new folder'
Debug.Print SaveAttachmentsTest(testpath, "*.*")    '<---all file types'
End Sub

This is the result in the immediate window:
Code:
Made folder: C:\Jack\
Made folder: C:\Jack\TestJ\
Made folder: C:\Jack\TestJ\FromAttachments\
Made folder: C:\Jack\TestJ\FromAttachments\March10\
Made folder: C:\Jack\TestJ\FromAttachments\March10\Polly\
Saved : err424.PNG
Made folder: C:\Jack\TestJ\FromAttachments\March10\Ethyl\
Saved : allAccessObjectsList.PNG
Saved : DataMacroForAuditLog.pptx
Saved : Employee.pdf
Saved : lynx2.jpg
Saved : MyLetter.docx
Saved : QR.xlsx
Saved : racoon.jpg
Saved : tigerRiver.jpg
9

Here's a graphic of the new folder and files resulting from this latest test of the demo.

FilesInNewFolder.PNG


The demo and this new test work as I expected and as reported previously.

Perhaps you should review your testing procedure and tell us exactly what didn't work for you.
Good luck.
 
Last edited:
Post a copy of your sample database and I'll look into it.
it does not work doesn't help anyone. Show your code and effort if you want focused help.

Based on your comments, I went back to the demo database and added a number of attachments to record id 3 "Ethyl" as shown in the graphic
View attachment 79701

Also, I modified the test routine
Code:
'routine to test the saveattachmentsTest function.
Sub testMakePath()
    Dim testpath As String
  'testpath = "C:\Jack\TestJ\FromAttachments"
  'Debug.Print SaveAttachmentsTest(testpath, "*.*g")
testpath = "C:\Jack\TestJ\FromAttachments\March10"  '<---new folder'
Debug.Print SaveAttachmentsTest(testpath, "*.*")    '<---all file types'
End Sub

This is the result in the immediate window:
Code:
Made folder: C:\Jack\
Made folder: C:\Jack\TestJ\
Made folder: C:\Jack\TestJ\FromAttachments\
Made folder: C:\Jack\TestJ\FromAttachments\March10\
Made folder: C:\Jack\TestJ\FromAttachments\March10\Polly\
Saved : err424.PNG
Made folder: C:\Jack\TestJ\FromAttachments\March10\Ethyl\
Saved : allAccessObjectsList.PNG
Saved : DataMacroForAuditLog.pptx
Saved : Employee.pdf
Saved : lynx2.jpg
Saved : MyLetter.docx
Saved : QR.xlsx
Saved : racoon.jpg
Saved : tigerRiver.jpg
9

Here's a graphic of the new folder and files resulting from this latest test of the demo.

View attachment 79702

The demo and this new test work as I expected and as reported previously.

Perhaps you should review your testing procedure and tell us exactly what didn't work for you.
Good luck.


Morning,

I modified the code remonving the "g" from routne and now is working also for me.

'routine to test the saveattachmentsTest function.
Sub testMakePath()
Dim testpath As String
'testpath = "C:\Jack\TestJ\FromAttachments"
'Debug.Print SaveAttachmentsTest(testpath, "*.*")
testpath = "C:\Jack\TestJ\FromAttachments\March10" '<---new folder'
Debug.Print SaveAttachmentsTest(testpath, "*.*") '<---all file types'
End Sub
 
Hi,
I'm a rookie in Access, and I have tried the code from the sample database and it works for me, thank you @jdraw.
However what would it take to export the documents from just one Record, like ("Record = " & Me!Record) and then delete the attachments in the same record?
Thanks in advance
 

Users who are viewing this thread

Back
Top Bottom