View Single Post
 
Old 12-21-2011, 11:07 PM
Catalin.B Catalin.B is offline Windows Vista Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Maybe i didn't understand what you need.
Try this: (in cells you must enter just the file name with extension, simply click on a cell , then start macro. It will open the file with the path specified in macro, and the name found in the active cell)
Code:
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
Sub openfiles()
Dim FileName, FilePath As String

    FileName = ActiveCell
FilePath = "E:\catalin\muzica" 'ThisWorkbook.Path  '"N:\video\movies\"
If Len(Dir(FilePath & "\" & FileName)) = 0 Then
MsgBox ("File " & FilePath & "\" & FileName & " not found!")
Exit Sub
    End If
    ActiveWorkbook.FollowHyperlink FilePath & FileName, NewWindow:=True
End Sub
Sub PlayVideo()
  Dim FileName As String
  Dim FilePath As String, retVal
  
    FileName = ActiveCell
    FilePath = "E:\catalin\muzica"
    
    retVal = ShellExecute(0&, "open", FileName, vbNullString, FilePath, 1&)
    
End Sub
Reply With Quote