CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 1999
    Posts
    8

    opening up a file

    Hello

    I've made a programme that creates a file and then saves it ( according to some name the user has entered) to the desktop. What I want is to create a short cut to opening up the file from the main form. At present I've tried inserting a view command on the form but each method I've tried creates errors! Its probably something really simply but any suggestions would be great.

    Thanks in advance


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: opening up a file

    If you know the location of the file (the full path) then you could use the ShellExecute API to have windows open that file in it's associated program. (ie .doc files open in Word etc). here is the API code...

    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_SHOWNORMAL = 1

    'call it like this:
    'now display the excel spreadsheet
    Dim fn as string
    fn = App.Path & "\myxlsfile.xls"
    iRetVal = ShellExecute(me.hwnd, vbNullString, fn, vbNullString, "c:\", SW_SHOWNORMAL)




    I hope this helps,
    john

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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

Featured