Opening a other type of document

Brass Contributor

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
  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

 

 

Hi

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

Regards

Should actually work.
Testing is above studying :)

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

@NikolinoDE 

Hi, Thank You i will try it!!! Just one question what does the $ in vba refers to??? My vba does not like it at all, gives a syntax error color red.

All this is red

              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

All this is red 

              Set large area = ActiveCell

Thank You

Regards

Kobus

@kobus1305 

The dollar sign indicates a string will be returned instead of a variant.

 

You can find more information and examples here

https://stackoverflow.com/questions/3389444/what-does-the-symbol-do-in-vba

 

Hope I could help you a little bit with your plans

 

Nikolino

I know I don't know anything (Socrates)

 

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)