0

Hi guys .. i wanted to open some of my files. like mswords that save in any of my folders. also wanted to open .txt, .jpg, html etc files.

any code for this..

i have an idea using

shell "location of exe"

but it open exe files only. i wanted to open/preview some of my documents.. any help will be much appreciated.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jaasaria
1

hi,
Try the following code:

'Declare the function to open any type of file

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

'Declare the variable of FileSytemObject to handle the files
'To get the filesystemobject select the Reference "Microsoft Scripting Runtime"
Dim f As New FileSystemObject
Private Sub Command1_Click()
CommonDialog1.ShowOpen

'To Open the Selecte File
Text1.Text = CommonDialog1.FileName
 OpenLocation (gParam_value & Text1.Text)
End Sub

'To Open the Selecte File
Private Function OpenLocation(ByVal WhichFilePath As String, Optional sParams As String = "", Optional sStartIn As String = vbNullString, Optional lngOpenMode As Long = 1) As Long
OpenLocation = ShellExecute(0, "Open", WhichFilePath, sParams, sStartIn, lngOpenMode)
End Function

Have a Great Day
Shailaja :)

Hi guys .. i wanted to open some of my files. like mswords that save in any of my folders. also wanted to open .txt, .jpg, html etc files.

any code for this..

i have an idea using

shell "location of exe"

but it open exe files only. i wanted to open/preview some of my documents.. any help will be much appreciated.

Edited by mike_2000_17: Fixed formatting

Votes + Comments
thx for the help dude. ^_^
0

perfect codes, for what i looking for.

thxx a lot manoshailu.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.