|
-
Dec 29th, 2005, 02:13 PM
#1
Thread Starter
Frenzied Member
shell question
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
-
Dec 29th, 2005, 02:16 PM
#2
Re: shell question
VB Code:
Shell "[i]path of image viewer[/i] " & filepath
-
Dec 29th, 2005, 02:18 PM
#3
Re: shell question
 Originally Posted by Pouncer
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
May I ask why you would want to attempt to open an .exe file or a jpg file using Notepad?
-
Dec 29th, 2005, 02:20 PM
#4
Thread Starter
Frenzied Member
Re: shell question
oh
but by the path of image viewer do you mean the extension name?
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
Last edited by Pouncer; Dec 29th, 2005 at 02:23 PM.
-
Dec 29th, 2005, 02:30 PM
#5
Re: shell question
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.
VB Code:
Shell "C:\Program Files\ACD Systems\ACDSee\ACDSee.exe " & "c:\windows\desktop\letter.jpg", vbNormalFocus
example, if i wish to view a jpg in ACDSee (an image viewer), then i need to shell its exe.
sorry, thought that you are interested in opening images, so provided a vague answer. hope this time i am correct and explained my point.
-
Dec 29th, 2005, 02:35 PM
#6
Re: shell question
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
-
Dec 29th, 2005, 02:42 PM
#7
Thread Starter
Frenzied Member
Re: shell question
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
-
Dec 29th, 2005, 02:50 PM
#8
Re: shell question
 Originally Posted by Pouncer
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,
but it is working for me. please post the code you used.
-
Dec 29th, 2005, 02:53 PM
#9
Re: shell question
instead of vbnormalfocus, use SW_NORMAL. it is a const value
VB Code:
Private Const SW_NORMAL = 1
-
Dec 29th, 2005, 03:37 PM
#10
Re: shell question
Actually Harsh, they both work the same as they both have the same value (1).
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 30th, 2005, 03:31 AM
#11
Re: shell question
 Originally Posted by RobDog888
Actually Harsh, they both work the same as they both have the same value (1). 
yes, i know that RobDog. 
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|