I have an Excel 2007 worksheet (xlsm) that is a text-only flat data-base (i.e. no spreadsheet functionality - just text in each cell). I've written a VBA procedure with a userform that creates a standard user interface to display the contents of any selected row.
Sitting beside the xlsm file is a folder of PDF files called: '##Filestore'. Some of the cells in the worksheet contain names of PDF files held in that folder.
When I see one of these filenames I want to be able to click on the adjacent label and display the contents of the file - e.g. by firing up the default PDF player such as Acrobat, much as one would by clicking directly on the file itself.
I can do this successfully (using different code) when the file is a JPG, or when the cell contains a URL, but I can't get it to display the PDF. Below is the code for the subroutine that was supposed to handle the PDF label click event:
However, when I run this is it generates my error exit message. The path shown in the error message seems to be correct, so it looks as if: 'ActiveWorkbook.FollowHyperlink' cannot run a PDF.Private Sub Label12_Click() Dim Link As String Link = ThumbnailFile.Text 'ThumbnailFile.Text is the PDF filename Link = ActiveWorkbook.Path & "\##Filestore\" & Link 'Link now holds full path to the file On Error GoTo NoCanDo Viewit: ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True Exit Sub NoCanDo: MsgBox "Cannot open " & Link End Sub
So how can one run a PDF from VBA in Excel 2007 (under Vista)?
Any advice gratefully received!