Forum Discussion

kobus1305's avatar
kobus1305
Brass Contributor
Nov 02, 2020

Opening a other type of document

I am trying to open a pdf, Acrobat Reader document, from within excel spreadsheet using hyperlink. I do have the Acrobat Reader Suite on the computer. Is it at all possible and can someone help??????

6 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor
    Additional info to the $ : The symbol $ is actually a holdover from the very first BASIC diaklects in which you had to declare string variables with the dollar sign. Sometimes I feel like I'm older than I think :). The $ functions do not accept null values and explicitly return results of the string type. Therefore you can confidently delete the dollar signs, in the times of the Ghz processors you don't need this function any more to run the code a bit (felt more) faster. Nikolino I know I don't know anything (Socrates)
  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor
    1. kobus1305 

     

    Maybe with VBA...but it depends on which version of Excel you have and which operating system.

    * Knowing the Excel version and operating system would also be an advantage :).

     

    'Class module table
    
    Option Explicit
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (_
          ByVal hwnd As Long, _
          ByVal lpOperation As String, _
          ByVal lpFile As String, _
          ByVal lpParameters As String, _
          ByVal lpDirectory As String, _
          ByVal nShowCmd As Long) As Long
    Private Sub Worksheet_FollowHyperlink (ByVal Target As Hyperlink)
    If Right $ (LCase $ (grgRbereich.Value), 4) = ".pdf" Then
         ChDrive $ Left (grgRbereich.Value, 3)
         ChDir $ Left (grgRange.Value, InStrRev (grgRange.Value, "\", -1))
         ShellExecute 0, "open", Dir $ (grgArea.Value), "", CurDir $ & "\", 1
    End If
    End Sub
    
    Private Sub Worksheet_SelectionChange (ByVal Target As Range)
    Set large area = ActiveCell
    End Sub

     

    Hope I understood the translation correctly and was able to help you.

     

    Thank you for your understanding and patience

     

    Nikolino

    I know I don't know anything (Socrates)

    * Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here

     

     

    • kobus1305's avatar
      kobus1305
      Brass Contributor

      Hi

      Thank You. It is Windows 7 Pro and Office Pro 2013

      Regards

      • NikolinoDE's avatar
        NikolinoDE
        Gold Contributor
        Should actually work.
        Testing is above studying 🙂

        Nikolino
        I know I don't know anything (Socrates)

Resources