VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Execute a file with any extension .doc,.xls,.bmp as long the application is install in windows

by KHONG YEW JOON (1 Submission)
Category: Libraries
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

Pass the file name and the function wil check from windows what is the application exe to run the file.Exp you want to run a abc.doc document from your program,u need to know msword.exe path and then you run the shell(applicate exe abc.doc,1) to execute the abc.doc
This work with any extension as long as it register to windows. etc .xls,.vbp,.doc

Inputs
strname = "Full path of your file" exp C:\Myfolder\Abc.doc or C:\abc.xls or c:\abc.bmp
Code Returns
Execute a file with any extension for more access www.efastclick.com
API Declarations
Private Declare Function FindExecutable _
Lib "shell32.dll" Alias "FindExecutableA" _
(ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal lpResult As String) As Long

Rate Execute a file with any extension .doc,.xls,.bmp as long the application is install in windows

Public Function runapp(strname As String, appname As String) As Long
Dim strResult As String
Dim lngResult As Long
Dim i, s_msg
 
 s_msg = MsgBox("Launch " & appname & " ?", vbYesNo, appname)
 If s_msg = vbYes Then
 strResult = String(255, 0)
 lngResult = FindExecutable(strname, vbNullString, strResult)
 strResult = Trim(Replace(strResult, "/dde", "", 1))
'run the file and not an .exe file
 i = Shell(Trim(Replace(strResult, vbNullChar, "", 1)) & " " & strname, 1)
 End If
 
 
End Function

Download this snippet    Add to My Saved Code

Execute a file with any extension .doc,.xls,.bmp as long the application is install in windows Comments

No comments have been posted about Execute a file with any extension .doc,.xls,.bmp as long the application is install in windows. Why not be the first to post a comment about Execute a file with any extension .doc,.xls,.bmp as long the application is install in windows.

Post your comment

Subject:
Message:
0/1000 characters