Results 1 to 11 of 11

Thread: shell question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: shell question

    VB Code:
    1. Shell "[i]path of image viewer[/i] " & filepath
    Show Appreciation. Rate Posts.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: shell question

    Quote 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?

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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.

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    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:
    1. 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.
    Show Appreciation. Rate Posts.

  6. #6
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    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:
    1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    2.   (ByVal hWnd As Long, ByVal lpOperation As String, _
    3.   ByVal lpFile As String, ByVal lpParameters As String, _
    4.   ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    5.  
    6. Private Const SW_NORMAL = 1
    7.  
    8. Private Sub Form_Load()
    9.  
    10.     ShellExecute Me.hWnd, "open", "C:\hello.PNG", vbNullString, vbNullString, SW_NORMAL
    11.  
    12. End Sub

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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

  8. #8
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: shell question

    Quote 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.
    Show Appreciation. Rate Posts.

  9. #9
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: shell question

    instead of vbnormalfocus, use SW_NORMAL. it is a const value
    VB Code:
    1. Private Const SW_NORMAL = 1
    Show Appreciation. Rate Posts.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  11. #11
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: shell question

    Quote 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.
    Show Appreciation. Rate Posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width