| | |
How to open files in my local machine.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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.
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.
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
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.
Last edited by manoshailu; Aug 6th, 2009 at 8:29 am.
![]() |
Similar Threads
- IIS works on local machine, but not on network (Windows Servers and IIS)
- Error 993 Partition contains open files. Use the operating system check utility (Windows NT / 2000 / XP)
- Finding if files exist.. file on local machine, problems on server (JSP)
- List of open files (C)
- how to backup mysql DB to local machine? and restore? (MySQL)
- copying mssql database on my local machine to a mysql database online (MySQL)
- Open files on double click (C#)
- IE won't open *local* PHP files anymore! (Web Browsers)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Getting Information in upperCase
- Next Thread: What is the Advantage and Disadvantage of using Control Array?
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





