leopurcell
New Member
- Joined
- Aug 14, 2020
- Messages
- 1
- Office Version
- 365
- 2019
- Platform
- MacOS
Excel 2019 for Mac
want to run a macro where pressing a button opens a PDF file.
at the moment, script manages to locate folder and opens a new window with contents, but does not sect and open the PDF file.
have been playing around with it as it used to work on windows, but no luck as of yet.
Sub open_file()
Dim file_to_open, chemin, file_name As String
Dim find_file As Range
On Error GoTo errorHandler
file_to_open = selection.Value
Set find_file = Sheets("Invoices").Columns(3).Find(file_to_open, LookAt:=xlWhole)
If find_file Is Nothing Then
MsgBox ("File not existing in the Invoices database.")
Else
file_name = find_file.Offset(0, 10)
chemin = "/user/_INVOICES/_" & find_file.Offset(0, 7) & Application.PathSeparator & file_name
ThisWorkbook.FollowHyperlink chemin
End If
Exit Sub
errorHandler:
MsgBox (chemin & " ---- File not existing in the Invoices database...")
End Sub
want to run a macro where pressing a button opens a PDF file.
at the moment, script manages to locate folder and opens a new window with contents, but does not sect and open the PDF file.
have been playing around with it as it used to work on windows, but no luck as of yet.
Sub open_file()
Dim file_to_open, chemin, file_name As String
Dim find_file As Range
On Error GoTo errorHandler
file_to_open = selection.Value
Set find_file = Sheets("Invoices").Columns(3).Find(file_to_open, LookAt:=xlWhole)
If find_file Is Nothing Then
MsgBox ("File not existing in the Invoices database.")
Else
file_name = find_file.Offset(0, 10)
chemin = "/user/_INVOICES/_" & find_file.Offset(0, 7) & Application.PathSeparator & file_name
ThisWorkbook.FollowHyperlink chemin
End If
Exit Sub
errorHandler:
MsgBox (chemin & " ---- File not existing in the Invoices database...")
End Sub