I have used the google maps code to open image files on my harddrive using field values.
It could be used for any file type as required, just change the file extension from .jpg.
It works perfectly unless there is no file named as per the feilds, then I get and error Single Step Macro; Err No 31665.
How can I get an error msg box to appear with "No file this name!" instead of the macro error??
Here is the code I adjusted to use;
Function OpenJPG(Address, City, State, Zip, Country)
Dim strAddress As String
strAddress = Nz(Address)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(City)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(State)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(Zip)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(Country)
strAddress = strAddress & IIf(strAddress = "", "", ".jpg")
If strAddress = "" Then
MsgBox "There is no address to map."
Else
Application.FollowHyperlink "C:\Users\MyDocs\Pictures\" & strAddress
End If
End Function
It could be used for any file type as required, just change the file extension from .jpg.
It works perfectly unless there is no file named as per the feilds, then I get and error Single Step Macro; Err No 31665.
How can I get an error msg box to appear with "No file this name!" instead of the macro error??
Here is the code I adjusted to use;
Function OpenJPG(Address, City, State, Zip, Country)
Dim strAddress As String
strAddress = Nz(Address)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(City)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(State)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(Zip)
strAddress = strAddress & IIf(strAddress = "", "", " ") & Nz(Country)
strAddress = strAddress & IIf(strAddress = "", "", ".jpg")
If strAddress = "" Then
MsgBox "There is no address to map."
Else
Application.FollowHyperlink "C:\Users\MyDocs\Pictures\" & strAddress
End If
End Function