I´m trying to make excel open files other than xls (word files, powerpoint files and pdf files). I´m only succeding with excel files (for obvious reasons). Is there a way to make excel use the default program to open a file. For example, if i´m opening a .doc file it should use Word but if i´m opening a .pdf it should use Acrobat (or another pdf reader). I´m using hyperlinks. I will show you what I got so far:
I have a list (Listbox2 in this case) with a code to load all the files in a specific folder:
Private Sub UserForm_Initialize()
Dim MyFolder As String
Dim MyFile As String
Dim j As Integer
USER = TextBox99
MyFolder = "C:\Example"
MyFile = Dir(MyFolder & "\*.*")
Do While MyFile <> ""
ListBox2.AddItem MyFile
MyFile = Dir
Loop
End Sub
Let´s say that in the listbox2 I have the file word.doc, powerpoint.ppt, excel.xls and acrobat.pdf. If I choose the file from the listbox2 and press a button with the following code:
Private Sub CommandButton14_Click()
Dim strFileandPath As String
strFileandPath = "C:\Example\" & UserForm1.ListBox2.Column(0)
Workbooks.Open strFileandPath
End Sub
It will only open the excel files. The other ones will get me an error. Is there a way to make Excel open any kind of file using the default program in the PC. Thanks for your attention!
Cheers