Results 1 to 4 of 4

Thread: How to open files

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2002
    Location
    Romania
    Posts
    13

    How to open files

    Hi, guys. I'm back and I have a problem.

    How can I open any file? For example, the user types in a path and vb opens the file( a doc, bmp,psd or any registered extension). Can you help me out?
    To make a program or not to make a program... that is the question. Or to destroy your computer's monitor, that's a second question

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    use ShellExecute if you want to launch default app.

    sample

    VB Code:
    1. Option Explicit
    2.  
    3.  
    4. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    5.                 (ByVal hwnd As Long, ByVal lpszOp As String, _
    6.                  ByVal lpszFile As String, ByVal lpszParams As String, _
    7.                  ByVal LpszDir As String, ByVal FsShowCmd As Long) _
    8.                  As Long
    9.  
    10. Private Sub Command1_Click()
    11.     'Open a web page
    12.     Dim l As Long
    13.     l = ShellExecute(Me.hwnd, "Open", "http://www.vbworld.com", "", "C:\", vbNormal)
    14. End Sub
    15.  
    16.  
    17. Private Sub Command2_Click()
    18.     'Open a document
    19.     Dim l As Long
    20.     l = ShellExecute(Me.hwnd, "Open", App.Path & "\Test.Doc", "", "C:\", vbNormal)
    21. End Sub
    -= a peet post =-

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2002
    Location
    Romania
    Posts
    13
    Thanx, man! It worked!
    To make a program or not to make a program... that is the question. Or to destroy your computer's monitor, that's a second question

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    you r welcome PNF

    it usually does
    -= a peet post =-

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