Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to open a file

How to open a file

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I'm trying to open a file of any type from an app built with VB6. Does anybody know the code to open a file, so that the program associated with this file type starts? [Maybe it's a stupid question, but i just don't know how to do this :confused: ] Thanks in advance, M_M_G

    M 1 Reply Last reply
    0
    • L Lost User

      I'm trying to open a file of any type from an app built with VB6. Does anybody know the code to open a file, so that the program associated with this file type starts? [Maybe it's a stupid question, but i just don't know how to do this :confused: ] Thanks in advance, M_M_G

      M Offline
      M Offline
      Matthew Hazlett
      wrote on last edited by
      #2

      Short of shelling out and running "Start (the name of the file)" there are other api ways. Tak a look here vbnet.mvps.org

      L 1 Reply Last reply
      0
      • M Matthew Hazlett

        Short of shelling out and running "Start (the name of the file)" there are other api ways. Tak a look here vbnet.mvps.org

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thx for your reply, but could you give a code example?

        R 1 Reply Last reply
        0
        • L Lost User

          Thx for your reply, but could you give a code example?

          R Offline
          R Offline
          RichardGrimmer
          wrote on last edited by
          #4

          I always use ShellExecute: 'ShellExecute Public 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 Public Const SW_NORMAL = 1 ' Displays the window normalised Public Const SW_SHOWMINIMIZED = 2 ' Displays the window minimised Public Const SW_SHOWMAXIMIZED = 3 ' Displays the window maximised Public Const SW_SHOWNOACTIVATE = 4 ' Displays the window normalised without focus Public Const SW_SHOW = 5 ' Activates a window at its current size Public Const SW_SHOWNA = 8 ' Displays the window at its current size without focus Public Const SW_SHOWDEFAULT = 10 ' Displays the window at its default size ShellExecute Me.hwnd, "Open", m_strFilename, "", "", SW_SHOWMAXIMIZED That should do everything you need! "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

          L 1 Reply Last reply
          0
          • R RichardGrimmer

            I always use ShellExecute: 'ShellExecute Public 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 Public Const SW_NORMAL = 1 ' Displays the window normalised Public Const SW_SHOWMINIMIZED = 2 ' Displays the window minimised Public Const SW_SHOWMAXIMIZED = 3 ' Displays the window maximised Public Const SW_SHOWNOACTIVATE = 4 ' Displays the window normalised without focus Public Const SW_SHOW = 5 ' Activates a window at its current size Public Const SW_SHOWNA = 8 ' Displays the window at its current size without focus Public Const SW_SHOWDEFAULT = 10 ' Displays the window at its default size ShellExecute Me.hwnd, "Open", m_strFilename, "", "", SW_SHOWMAXIMIZED That should do everything you need! "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Many thanks! The code is working great (with a few mods)!

            R 1 Reply Last reply
            0
            • L Lost User

              Many thanks! The code is working great (with a few mods)!

              R Offline
              R Offline
              RichardGrimmer
              wrote on last edited by
              #6

              M_M_G wrote: with a few mods What did you have to change? (Not having a dig, just curious!) "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

              L 1 Reply Last reply
              0
              • R RichardGrimmer

                M_M_G wrote: with a few mods What did you have to change? (Not having a dig, just curious!) "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                All the 'Public' stuff didn't work. It also didn't work properly with the 'SW_SHOWMAXIMIZED' argument.

                S 1 Reply Last reply
                0
                • L Lost User

                  All the 'Public' stuff didn't work. It also didn't work properly with the 'SW_SHOWMAXIMIZED' argument.

                  S Offline
                  S Offline
                  Steve S
                  wrote on last edited by
                  #8

                  The 'Public' stuff works if you have the code fragment in a global BAS module, not inside a FRM file, AFAIR. Not all apps honour the SW_SHOW* flags, and it is optional. Steve S

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups