View/Load Access attachment from excel userform

AceandVecky

New Member
Joined
Jun 7, 2019
Messages
7
Good Day.
Please Help me or advise suggestion or Tips on how to load, View or Download an attachment from a selected record in an MS Access table using excel macro.

I can however modify/Add/Delete data in access using an ADODB Connection but i dont have experience in working with attachment. Thanks in advance.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,993
Normally you just dbl-click the attachment,then click SAVE.
 

AceandVecky

New Member
Joined
Jun 7, 2019
Messages
7
@ranman256
yeah thats correct. but what Im trying to achieve is do that using a macro code from Excel. I have an excel userform as a frontend and an access database as the backend.

Thanks
 

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,993
something like :

Code:
Dim rst As ADODB.Recordset
Dim conn As New ADODB.Connection

vTarg = "c:\temp\myFile.jpg"

If Not FileExists(vTarg) Then
'extract photo attachement
sConnStr = "your connection string"
conn.ConnectionString = sConnStr
conn.Open

    '1st rst is the table
sSql = "select * from tInstallDb"
Set rst = conn.Execute(sSql)
'2nd rst is the attachment (rst in a rst)
Set rstChild = rst.Fields(0).Value
rstChild.Fields("FileData").SaveToFile vTarg
End If

Code:
Public Function FileExists(ByVal pvFile) As Boolean
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(pvFile)
Set fso = Nothing
End Function
 

Watch MrExcel Video

Forum statistics

Threads
1,133,575
Messages
5,659,616
Members
418,514
Latest member
radonwilson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top