//************************************** // for :Easy ShellExecute replacement without API calls //************************************** Free to use, just vote for me ;) //************************************** // Name: Easy ShellExecute replacement without API calls // Description:With only a few lines of code you will be able to open any document with the associated executable file or, if no association present, you will be prompted to open the file with the program you choose. This can also be used to execute an executable file. No API calls used! // By: John Willemse (from psc cd) // // // Inputs:Simply pass the full path to the file in a string to function. // // Returns:Returns true if succeeded, false in case of an error. // //Assumes:To use this function, simply put the code in a class and call it, e.g.: Dim retVal As Boolean retVal = ExecuteFile("c:\temp\myword.doc") If retVal = False then MsgBox("Something went wrong!") Else MsgBox("Succeeded!") End If That's all! Check the additional properties of a Process() for more options, like waiting for the process to finish, etc. // //Side Effects:None //************************************** Private Function ExecuteFile(ByVal FileName As String) As Boolean Dim myProcess As New Process() myProcess.StartInfo.FileName = FileName myProcess.StartInfo.UseShellExecute = True myProcess.StartInfo.RedirectStandardOutput = False myProcess.Start() End Function