link to a file (1 Viewer)

kitty77

Registered User.
Local time
Today, 16:08
Joined
May 27, 2019
Messages
712
I'm using the following code with a button... How can I make it look in another folder location too.
Basically, if the file is in one folder or the other folder. I want to be able to look in either one.

Dim strFileName As String
Dim strFileExists As String

strFileName = "\\folder123\" & [Mdid] & "\Invoices\" & [Minvoiceno] & ".pdf"
strFileExists = Dir(strFileName)

If strFileExists = "" Then
MsgBox "The selected file doesn't exist"
Else
Application.FollowHyperlink "\\folder123\" & [Mdid] & "\Invoices\" & [Minvoiceno] & ".pdf"
End If

End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:08
Joined
Aug 30, 2003
Messages
36,125
Along the lines of:

Code:
strFileName = "\\folder123\" & [Mdid] & "\Invoices\" & [Minvoiceno] & ".pdf"
strFileExists = Dir(strFileName)

If strFileExists = "" Then
  strFileName = "other location"
  strFileExists = Dir(strFileName)
  If strFileExists = "" Then
    MsgBox "The selected file doesn't exist"
  Else
    Application.FollowHyperlink "other location"
  End If
Else
  Application.FollowHyperlink "\\folder123\" & [Mdid] & "\Invoices\" & [Minvoiceno] & ".pdf"
End If
 

Users who are viewing this thread

Top Bottom