Function Open Image File – VBA

We use this function to open the image file. You can put this function in the module then call it anywhere in your Access database.

Function OpenImageFile(ByVal strFilePath As String) As String
 If IsNull(strFilePath) Then
    MsgBox "File Not Found", vbExclamation, "Action Cancelled"    
        Application.FollowHyperlink strFilePath
   End If
End Function

How to Use It:

You can call this function on any form like:

Dim myPath as string
myPath = "C:\Users\Test\Downloads\report.png"
call OpenImageFile(myPath)


Related posts