Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
- Dim testo As String
- Dim nomefile As String
- Dim path As String
- On Error Resume Next
- If Target.Column = 5 Then
- path = "C:UsersAlex"
- testo = path & Cells(Target.Row, 5)
- nomefile = Dir(Left(testo, Len(testo)) & "*.pdf")
- If nomefile = "" Then
- MsgBox "File non trovato", vbCritical, "ATTENZIONE"
- Exit Sub
- End If
- Do
- Shell "C:Program Files (x86)AdobeReader 11.0ReaderAcroRd32.exe " & path & nomefile, vbMaximizedFocus
- nomefile = Dir
- Loop While nomefile <> ""
- End If
- End Sub
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
- Dim testo As String
- Dim FSO As Object
- Dim Folder As Object
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set Folder = FSO.GetFolder("C:UsersAlex")
- ...
- ...
- testo = path & Cells(Target.Row, 5)
- nomefile = FindFile(testo, Folder, FSO)
- End Sub
- Function FindFile(FileName As String, Folder As Object, ByRef FSO As Object) As String
- DoEvents
- If FSO.FileExists(Folder & "" & FileName & ".pdf") Then
- FindFile = Folder & "" & FileName & ".pdf"
- Exit Function
- End If
- Dim SubFolder As Object
- For Each SubFolder In Folder.SubFolders
- FindFile = FindFile(FileName, SubFolder, FSO)
- Next
- End Function
- Function FindFile(FileName As String, Folder As Object, ByRef FSO As Object) As String
- DoEvents
- If FSO.FileExists(Folder & "" & FileName & "*.pdf*") Then
- FindFile = Folder & "" & FileName & "*.pdf*"
- Exit Function
- End If
- Dim SubFolder As Object
- For Each SubFolder In Folder.SubFolders
- FindFile = FindFile(FileName, SubFolder, FSO)
- Next
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
- Dim testo As String
- Dim nomefile As String
- Dim FSO As Object
- Dim Folder As Object
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set Folder = FSO.GetFolder("C:UsersAlex")
- If Target.Column = 5 Then
- testo = Cells(Target.Row, 5)
- nomefile = FindFile(testo, Folder, FSO)
- If nomefile = "" Then
- MsgBox "File not found!", vbCritical, "WARNING"
- Exit Sub
- End If
- CreateObject("WScript.Shell").Run nomefile
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement