Shell "notepad " & filepath, vbNormalFocus
thats fine, but what if the file is a jpg or png or an exe or any others etc
how can i make it shell open the file like that automatically
Printable View
Shell "notepad " & filepath, vbNormalFocus
thats fine, but what if the file is a jpg or png or an exe or any others etc
how can i make it shell open the file like that automatically
VB Code:
Shell "[i]path of image viewer[/i] " & filepath
May I ask why you would want to attempt to open an .exe file or a jpg file using Notepad?Quote:
Originally Posted by Pouncer
oh :eek:
but by the path of image viewer do you mean the extension name? :confused:
im still not sure
is there no way i can make it shell execure automatically? by just putting
Shell C:\hello.PNG (this would open it in whatever image view i have)
Shell C:\hello.exe (this would start the exe)
etc
etc
i wasnt trying to open the exe or jpg with the notepad thing, the notepad is what i have for my text files but was looking for a way to open other file types automativcally
by path of image viewer, i mean path of the app. in which you wish to open the images. you need to shell different app to view/open different types of files.
example, if i wish to view a jpg in ACDSee (an image viewer), then i need to shell its exe.VB Code:
Shell "C:\Program Files\ACD Systems\ACDSee\ACDSee.exe " & "c:\windows\desktop\letter.jpg", vbNormalFocus
sorry, thought that you are interested in opening images, so provided a vague answer. hope this time i am correct and explained my point.
Use Shellexecute for non executable files, i.e not a exe, com, scr or bat file.
Shellexecute will open the file with the default viewer.
VB Code:
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 Private Const SW_NORMAL = 1 Private Sub Form_Load() ShellExecute Me.hWnd, "open", "C:\hello.PNG", vbNullString, vbNullString, SW_NORMAL End Sub
what about this
ShellExecute 0, "Open", filePath, vbNullString, vbNullString, vbNormalFocus
will that open all file types?
it just worked for my jpg file, but the full page doesnt come on the desktop, i have to click on it in the taskbar to display it properly
Pouncer,Quote:
Originally Posted by Pouncer
but it is working for me. please post the code you used.
instead of vbnormalfocus, use SW_NORMAL. it is a const valueVB Code:
Private Const SW_NORMAL = 1
Actually Harsh, they both work the same as they both have the same value (1). :)
yes, i know that RobDog. :)Quote:
Originally Posted by RobDog888
just a guess if, by any chance, vbNormalFocus is functioning abnormally in this API. thats why i also asked Pouncer to post the code s/he used.