DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Using Shell ?

  1. #1
    Richard Keenan Guest

    Using Shell ?


    Sorry if this is a stupid question - but I am a novice;

    I have a node in a treeview directory that launches an MS Word file when
    the user selects it. Works OK & reads;

    nd1.URL1 = "C:\one.doc"

    However, I actually need the node to launch a different application which
    then opens the Word document inside itself via a command line parameter.
    From a DOS prompt this reads;

    hd5start /tf=pathname

    (hd5start is apps .exe file & /tf=pathname is the path to the Word document).
    What I don't know how to do is to put these two together so that they work
    in VB !! Anyone help a newbie ?



  2. #2
    Shawn K. Hall Guest

    Re: Using Shell ?

    Richard,

    If all you need to do is shell to hd5start with the pathname actually
    being the path indicated by nd1.URL1 it should be this simple:
    Shell "hd5start /tf=" & nd1.URL1

    With that statement above, assuming nd1.URL1 = "C:\one.doc" then the
    command sent to the command line would be: "hd5start /tf=C:\one.doc"

    Depending how the program you send it to parses the command line this
    still may not work. If it "expects" you to put it in quotes then
    you'll need to add quotes around it too. Try it without the quotes
    first. Try it with a file that has long-filename format (like C:\My
    Documents\one.doc) and see if it still opens it without a problem. If
    it does then it probably won't be a problem. If it doesn't then you'll
    need to add quotes around it and make sure that works right.

    Good luck,
    --
    Shawn K. Hall
    Programmer / Analyst
    *Please* post/respond in the newsgroups!
    http://i.am/shawnkhall


    "Richard Keenan" <lee.corless@btinternet.com> wrote in message
    news:39161000$1@news.devx.com...
    >
    > Sorry if this is a stupid question - but I am a novice;
    >
    > I have a node in a treeview directory that launches an MS Word file

    when
    > the user selects it. Works OK & reads;
    >
    > nd1.URL1 = "C:\one.doc"
    >
    > However, I actually need the node to launch a different application

    which
    > then opens the Word document inside itself via a command line

    parameter.
    > From a DOS prompt this reads;
    >
    > hd5start /tf=pathname
    >
    > (hd5start is apps .exe file & /tf=pathname is the path to the Word

    document).
    > What I don't know how to do is to put these two together so that

    they work
    > in VB !! Anyone help a newbie ?




  3. #3
    Richard Keenan Guest

    Re: Using Shell ?


    Thanks for this - it works...but !

    Unfortunately the program is now shelling to hd5start automatically when
    I run the script ! I just need it to run when the user selects the node called
    nd1

    Any idea why would be really appreciated !

    Thanks, Lee




    "Shawn K. Hall" <shawnkhall@iname.com> wrote:
    >Richard,
    >
    >If all you need to do is shell to hd5start with the pathname actually
    >being the path indicated by nd1.URL1 it should be this simple:
    > Shell "hd5start /tf=" & nd1.URL1
    >
    >With that statement above, assuming nd1.URL1 = "C:\one.doc" then the
    >command sent to the command line would be: "hd5start /tf=C:\one.doc"
    >
    >Depending how the program you send it to parses the command line this
    >still may not work. If it "expects" you to put it in quotes then
    >you'll need to add quotes around it too. Try it without the quotes
    >first. Try it with a file that has long-filename format (like C:\My
    >Documents\one.doc) and see if it still opens it without a problem. If
    >it does then it probably won't be a problem. If it doesn't then you'll
    >need to add quotes around it and make sure that works right.
    >
    >Good luck,
    >--
    >Shawn K. Hall
    >Programmer / Analyst
    >*Please* post/respond in the newsgroups!
    >http://i.am/shawnkhall
    >
    >
    >"Richard Keenan" <lee.corless@btinternet.com> wrote in message
    >news:39161000$1@news.devx.com...
    >>
    >> Sorry if this is a stupid question - but I am a novice;
    >>
    >> I have a node in a treeview directory that launches an MS Word file

    >when
    >> the user selects it. Works OK & reads;
    >>
    >> nd1.URL1 = "C:\one.doc"
    >>
    >> However, I actually need the node to launch a different application

    >which
    >> then opens the Word document inside itself via a command line

    >parameter.
    >> From a DOS prompt this reads;
    >>
    >> hd5start /tf=pathname
    >>
    >> (hd5start is apps .exe file & /tf=pathname is the path to the Word

    >document).
    >> What I don't know how to do is to put these two together so that

    >they work
    >> in VB !! Anyone help a newbie ?

    >
    >



  4. #4
    Shawn K. Hall Guest

    Re: Using Shell ?

    You're welcome Lee,

    << Any idea why [snip] >>

    I think that's pretty well impossible to know without seeing your
    event code.

    Assuming that nd1 is a declared node object (like form level or
    something) you could do this:

    '/begin vaporcode
    Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    If Node Is nd1 Then ...[the other stuff]
    End Sub
    '/end vaporcode

    That will check the two reference pointers and see if they're both
    pointing to the same thing. If they are then "Node" really *is* nd1 so
    it will run the other stuff.

    Regards,

    Shawn K. Hall
    Programmer / Analyst
    *Please* post/respond in the newsgroups!
    http://i.am/shawnkhall


    "Richard Keenan" <lee.corless@btinternet.com> wrote in message
    news:39177f12$1@news.devx.com...
    >
    > Thanks for this - it works...but !
    >
    > Unfortunately the program is now shelling to hd5start automatically

    when
    > I run the script ! I just need it to run when the user selects the

    node called
    > nd1
    >
    > Any idea why would be really appreciated !
    >
    > Thanks, Lee




  5. #5
    Richard Keenan Guest

    Re: Using Shell ?


    Thanks again Shawn. I just have one FINAL question (I promise) but understand
    if you don't have the time to get back..
    My code is so small that I've included it below, in the last hope that I
    can sort this out before Friday ! Any pointer would be massively appreciated.
    Lee


    Private Sub Form_Load()
    Dim Nodes As pvxNodes
    Dim RootNode As pvxNode
    Dim Node As pvxNode
    Dim ChildNode As pvxNode
    Dim nd1 As pvxNode

    PVExplorer1.TreeView.Indentation = 20

    ' Add a series of Node objects to the TreeView Nodes collection
    Set Nodes = PVExplorer1.TreeView.Nodes

    'this sets the main folder
    Set RootNode = Nodes.Add(Nothing, pvxLast, "Divorce Module", 0, 0)
    RootNode.ViewerType = pvxNoPane
    RootNode.BoldText = True

    'this sets the Divorce Documents subfolder
    Set Node = Nodes.Add(RootNode, pvxLast, "Divorce Documents", 0, 0)
    Node.ViewerType = pvxNoPane
    Node.BoldText = True

    Set nd1 = Nodes.Add(Node, pvxLast, "Test", 2, 2)
    nd1.URL1 = "c:\divorce module documents\12 Client chase up letter for
    Decree Nisi Docs.dot"
    nd1.ViewerType = pvxWebBrowserPane

    End Sub


    Private Sub PVExplorer1_NodeClick(ByVal Node As Object)
    If Node Is nd1 Then Shell "hd5start /aa /da /tf" & nd1.URL1
    End Sub


    "Shawn K. Hall" <shawnkhall@iname.com> wrote:
    >You're welcome Lee,
    >
    ><< Any idea why [snip] >>
    >
    >I think that's pretty well impossible to know without seeing your
    >event code.
    >
    >Assuming that nd1 is a declared node object (like form level or
    >something) you could do this:
    >
    >'/begin vaporcode
    >Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    > If Node Is nd1 Then ...[the other stuff]
    >End Sub
    >'/end vaporcode
    >
    >That will check the two reference pointers and see if they're both
    >pointing to the same thing. If they are then "Node" really *is* nd1 so
    >it will run the other stuff.
    >
    >Regards,
    >
    >Shawn K. Hall
    >Programmer / Analyst
    >*Please* post/respond in the newsgroups!
    >http://i.am/shawnkhall
    >
    >
    >"Richard Keenan" <lee.corless@btinternet.com> wrote in message
    >news:39177f12$1@news.devx.com...
    >>
    >> Thanks for this - it works...but !
    >>
    >> Unfortunately the program is now shelling to hd5start automatically

    >when
    >> I run the script ! I just need it to run when the user selects the

    >node called
    >> nd1
    >>
    >> Any idea why would be really appreciated !
    >>
    >> Thanks, Lee

    >
    >



  6. #6
    Shawn K. Hall Guest

    Re: Using Shell ?

    Hello again Richard,

    I think you should read up in the MSDN help file about "Scope". For
    the quick and easy fix, ALWAYS use "Option Explicit" in your apps.
    EVERY module needs to have the first line read:

    Option Explicit


    If you use Option Explicit it will tell you when you try to
    run/compile that your variable has not been declared, in your
    situation it would say something like "variable not declared in this
    context".

    When you declare a variable within a module, like at the top with
    something like
    Private sMyString as String
    then that string is available throughout the entire module - to any
    procedures or functions that want to play with it.

    If you declare it within a procedure, it will be created and destroyed
    *within the procedure*. Unless you define it as "static" (which even
    then, though it may exist across several incarnations of the single
    procedure, it *only* exists within the "Scope" of that procedure) it
    will *always* be destroyed at the end of the procedure. Within your
    code you have declared the vairables (like nd1) within Form_Load,
    which means that they will not exist when it comes to the point of
    PVExplorer1_NodeClick. If you'd like to be able to use the "If Node Is
    nd1" syntax, you *must* declare the variable with greater scope (at
    the top of the module instead of in Form_Load).

    To make it so all of your "new" code already includes "Option
    Explicit" go to "Tools">"Options" and check the box that says "Require
    Variable Declaration".

    Regards,

    Shawn K. Hall
    Programmer / Analyst
    *Please* post/respond in the newsgroups!
    http://i.am/shawnkhall


    "Richard Keenan" <lee.corless@btinternet.com> wrote in message
    news:39187f3f$1@news.devx.com...
    >
    > Thanks again Shawn. I just have one FINAL question (I promise) but

    understand
    > if you don't have the time to get back..
    > My code is so small that I've included it below, in the last hope

    that I
    > can sort this out before Friday ! Any pointer would be massively

    appreciated.
    > Lee
    >
    >
    > Private Sub Form_Load()
    > Dim Nodes As pvxNodes
    > Dim RootNode As pvxNode
    > Dim Node As pvxNode
    > Dim ChildNode As pvxNode
    > Dim nd1 As pvxNode
    >
    > PVExplorer1.TreeView.Indentation = 20
    >
    > ' Add a series of Node objects to the TreeView Nodes collection
    > Set Nodes = PVExplorer1.TreeView.Nodes
    >
    > 'this sets the main folder
    > Set RootNode = Nodes.Add(Nothing, pvxLast, "Divorce Module", 0,

    0)
    > RootNode.ViewerType = pvxNoPane
    > RootNode.BoldText = True
    >
    > 'this sets the Divorce Documents subfolder
    > Set Node = Nodes.Add(RootNode, pvxLast, "Divorce Documents", 0,

    0)
    > Node.ViewerType = pvxNoPane
    > Node.BoldText = True
    >
    > Set nd1 = Nodes.Add(Node, pvxLast, "Test", 2, 2)
    > nd1.URL1 = "c:\divorce module documents\12 Client chase up

    letter for
    > Decree Nisi Docs.dot"
    > nd1.ViewerType = pvxWebBrowserPane
    >
    > End Sub
    >
    >
    > Private Sub PVExplorer1_NodeClick(ByVal Node As Object)
    > If Node Is nd1 Then Shell "hd5start /aa /da /tf" & nd1.URL1
    > End Sub




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center