Auto-boot vb program from cd

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J French

    #16
    Re: Auto-boot vb program from cd

    On Mon, 17 Nov 2003 19:33:54 -0000, "Roy Riddex"
    <roy_riddexNOSP AM@blueyonder.c o.uk> wrote:

    <snip>[color=blue]
    >As I said, I don't want VB to do anything with the file other than to act as
    >a shortcut to the file.
    >Here goes, I have a simple form which I hope to autorun when a cd is
    >inserted into the drive. All I want the form to do is provide links (via
    >command buttons) to allow a user to view the files. I need to be able to
    >provide links to word, access, excel and powerpoint files. I am completely
    >new to VB6 (aint programmed for over 10 years since school on bbc micro) and
    >I assumed having links to other files would be easy but so far it's been a
    >nightmare.
    >Can someone please tell me in simple terms how to link the pressing of a
    >command button to the opening of word and the opening of a document, or the
    >opening of powerpoint and the opening of a powerpoint file etc....[/color]

    1. Goto www.AllAPI.net
    2. Download their API Guide
    3. Look inside it for ShellExecute

    HTH

    Comment

    • Roy Riddex

      #17
      Re: Auto-boot vb program from cd

      [color=blue]
      >
      > 1. Goto www.AllAPI.net
      > 2. Download their API Guide
      > 3. Look inside it for ShellExecute
      >[/color]

      Downloaded the API guide. Their example opens an email. Since I haven't
      learned anything as advanced as shellexecute in college yet I am still
      struggling to apply shellexecute to my own files.
      Can someone please post a piece of code that will run MS Word and display
      the contents of a file from "c:/my documents/college stuff/interlet.doc"
      with the click of a command button.
      Can the same code be applied to different file types i.e. files created in
      word, access, powerpoint etc.?


      Comment

      • Steve Gerrard

        #18
        Re: Auto-boot vb program from cd


        "Roy Riddex" <roy_riddexNOSP AM@blueyonder.c o.uk> wrote in message
        news:vwRub.1652 $Hz.1434@news-binary.blueyond er.co.uk...[color=blue]
        >[color=green]
        > >
        > > 1. Goto www.AllAPI.net
        > > 2. Download their API Guide
        > > 3. Look inside it for ShellExecute
        > >[/color]
        >
        > Downloaded the API guide. Their example opens an email. Since I[/color]
        haven't[color=blue]
        > learned anything as advanced as shellexecute in college yet I am still
        > struggling to apply shellexecute to my own files.
        > Can someone please post a piece of code that will run MS Word and[/color]
        display[color=blue]
        > the contents of a file from "c:/my documents/college[/color]
        stuff/interlet.doc"[color=blue]
        > with the click of a command button.
        > Can the same code be applied to different file types i.e. files[/color]
        created in[color=blue]
        > word, access, powerpoint etc.?
        >
        >[/color]

        Their example opens an email because they specified
        "mailto:KPDTeam @Allapi.net" as the file name. If you specify "c:/my
        documents/college stuff/interlet.doc", then Windows will open that file,
        with whatever program happens to be registered for .doc files (Word, no
        doubt). Ditto for any file, if it has a registered file type.
        ShellExecute is the programming equivalent of double-clicking on a file.


        Comment

        • J French

          #19
          Re: Auto-boot vb program from cd

          On Wed, 19 Nov 2003 21:36:54 -0800, "Steve Gerrard"
          <notstevegerrar d@comcast.net> wrote:

          <snip>[color=blue]
          >
          >Their example opens an email because they specified
          >"mailto:KPDTea m@Allapi.net" as the file name. If you specify "c:/my
          >documents/college stuff/interlet.doc", then Windows will open that file,
          >with whatever program happens to be registered for .doc files (Word, no
          >doubt). Ditto for any file, if it has a registered file type.
          >ShellExecute is the programming equivalent of double-clicking on a file.
          >[/color]

          Absolutely

          However, the OP might also be interested in the FindExecutable API
          - one gets a little more info on what is going on
          - and a bit more control



          Comment

          • Roy Riddex

            #20
            Re: Auto-boot vb program from cd

            [color=blue][color=green]
            > >Their example opens an email because they specified
            > >"mailto:KPDTea m@Allapi.net" as the file name. If you specify "c:/my
            > >documents/college stuff/interlet.doc", then Windows will open that file,
            > >with whatever program happens to be registered for .doc files (Word, no
            > >doubt). Ditto for any file, if it has a registered file type.
            > >ShellExecute is the programming equivalent of double-clicking on a file.
            > >[/color]
            >
            > Absolutely
            >
            > However, the OP might also be interested in the FindExecutable API
            > - one gets a little more info on what is going on
            > - and a bit more control
            >
            >
            >[/color]

            Ok, this is really starting to take over my life now. It still doesn't seem
            to work. I lifted the code straight from the API Guide and made the changes
            as advised by Steve Gerrard. I'm unsure if the Private Declare Function part
            is in the correct place(never used this before); I tried keeping it
            alongside Private Sub cmdSelect but it was automatically moved above the
            line and into the previous sub. I'm getting nearer to a difinitive answer,
            please help.
            Here's the part of my program causing me problems:

            Option Explicit
            Private Declare Function ShellExecute Lib "shell32.dl l" Alias
            "ShellExecu teA" (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
            Dim Password As String
            Dim Counter As Integer
            Dim HelpFile As String
            etc.
            etc.
            Private Sub cmdSelect_Click ()
            Const SW_SHOWNORMAL = 1
            ShellExecute Me.hwnd, vbNullString, "c:/My Documents/College
            Subjects/ITAS/Word/Interlet.doc", vbNullString, "C:\", SW_SHOWNORMAL
            End Sub


            Comment

            • J French

              #21
              Re: Auto-boot vb program from cd

              On Thu, 20 Nov 2003 12:16:53 -0000, "Roy Riddex"
              <roy_riddexNOSP AM@blueyonder.c o.uk> wrote:

              Probably ... you need to surround things with quotes

              Not sure

              Look into the other thing I suggested, FindExecutable
              (note: it needs a dummy file)


              I'm rather stuffed now, an extended lunch

              But tomorrow I'll probably do what I detest
              - just post some code

              Programmers should NEVER use code that they do not totally understand

              Comment

              • Steve Gerrard

                #22
                Re: Auto-boot vb program from cd


                "Roy Riddex" <roy_riddexNOSP AM@blueyonder.c o.uk> wrote in message
                news:Vg2vb.1066 3$zQ.8983@news-binary.blueyond er.co.uk...[color=blue]
                >
                > Here's the part of my program causing me problems:
                >
                > Option Explicit
                > Private Declare Function ShellExecute Lib "shell32.dl l" Alias
                > "ShellExecu teA" (ByVal hwnd As Long, ByVal lpOperation As String,[/color]
                ByVal[color=blue]
                > lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As[/color]
                String,[color=blue]
                > ByVal nShowCmd As Long) As Long
                > Dim Password As String
                > Dim Counter As Integer
                > Dim HelpFile As String
                > etc.
                > etc.
                > Private Sub cmdSelect_Click ()
                > Const SW_SHOWNORMAL = 1
                > ShellExecute Me.hwnd, vbNullString, "c:/My Documents/College
                > Subjects/ITAS/Word/Interlet.doc", vbNullString, "C:\", SW_SHOWNORMAL
                > End Sub
                >
                >[/color]

                This should work fine. I copied your code, substituted the path to a
                file on my computer, ran it, and it opened up my word document straight
                away. Maybe:
                1. You are using forward slashes instead of back slashes, i.e. it should
                be "c:\My Documents\Colle ge..."
                2. Your path is not correct. On my XP machine, "My Documents" is
                "C:\Documen ts and Settings\Steve\ My Documents"
                3. I assume the line breaks are from your mail program, and you have the
                lines intact in your code. When you say it causes problems, it would be
                more helpful if you specified what problem. Does it compile? Does it
                run? Does anything happen? Do you get an error message?


                Comment

                Working...