View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default launch any file type from excel macro

Use the hyperlink worksheet function to build a hyperlink


or if you want code, just use the shell command with fully qualified file
name.

As long as the extension is mapped to an application, it should work the
same as double clicking on the file in explorer.

--
Regards,
Tom Ogilvy

"arron laing " wrote in message
...
I have a macro that lists all the files relating to a project in a
single worksheet. As the file list and the directory tree is very
large, I am trying to write a macro that will launch the selected file
from the list.

I have managed to work out how to launch .xls and .doc files
using the following code by taking 'file' from the active cell


' file is the full path

If Right(file, 3) = "xls" Then
Workbooks.Open file
End If

If Right(file, 3) = "doc" Then
Set wdapp = CreateObject("Word.Application")
With wdapp
Documents.Open file
Visible = True
End With
End If

but this seems a bit cumbersome as there are CAD files, MS project
files, JPGs, Acrobat files etc.

Is there a universal command that will launch any file type or some
other clever work around.

Cheers

Arron


---
Message posted from http://www.ExcelForum.com/