954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to open files in my local machine.

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.

jaasaria
Junior Poster
123 posts since Jul 2007
Reputation Points: 10
Solved Threads: 1
 

hi,
Try the following code:

[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.

manoshailu
Junior Poster
105 posts since Jun 2007
Reputation Points: 34
Solved Threads: 10
 

perfect codes, for what i looking for.

thxx a lot manoshailu.

jaasaria
Junior Poster
123 posts since Jul 2007
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You