vb run vbs ?

I have a large number of VBS files that create webpages from a database.

Can I run them from a VB program ....
e.g.

command button 1 will run the first vbs
command button 2 will run the second vbs.
etc .....
command button 20 will run ALL the vbs ...

if so .. can someone show me how to do this please ... please ......



Comments

  • [b][red]This message was edited by lionb at 2005-9-21 12:34:59[/red][/b][hr]
    : I have a large number of VBS files that create webpages from a database.
    :
    : Can I run them from a VB program ....
    : e.g.
    :
    : command button 1 will run the first vbs
    : command button 2 will run the second vbs.
    : etc .....
    : command button 20 will run ALL the vbs ...
    :
    : if so .. can someone show me how to do this please ... please ......
    :
    :
    :
    :
    You can use Microsoft Windows Script Control. If don't have you can download it from http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
    Some inforamtion how to use Script Control may be found here http://www.builderau.com.au/program/windows/0,39024644,20265370,00.htm
    If you won't be able to use link grom here copy and paste it to the address bar.

  • : [b][red]This message was edited by lionb at 2005-9-21 12:34:59[/red][/b][hr]
    : : I have a large number of VBS files that create webpages from a database.
    : :
    : : Can I run them from a VB program ....
    : : e.g.
    : :
    : : command button 1 will run the first vbs
    : : command button 2 will run the second vbs.
    : : etc .....
    : : command button 20 will run ALL the vbs ...
    : :
    : : if so .. can someone show me how to do this please ... please ......
    : :
    : :
    : :
    : :
    : You can use Microsoft Windows Script Control. If don't have you can download it from http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp
    : Some inforamtion how to use Script Control may be found here http://www.builderau.com.au/program/windows/0,39024644,20265370,00.htm
    : If you won't be able to use link grom here copy and paste it to the address bar.
    :
    :
    Thanks Lionb ....

    I tried to d/l it but it keeps going throug MS's "who are you ,... what you running " thing but doesn'tr d/l ....

    Anyother way using ordinary VB ?




  • : I tried to d/l it but it keeps going throug MS's "who are you ,... what you running " thing but doesn'tr d/l ....
    :
    : Anyother way using ordinary VB ?
    :
    :
    Not sure I undesrstand what you mean saing 'keeps going throug MS's "who are you ,... what you running " ' Do you have problem to download Script Control or some other problems?

  • :
    : : I tried to d/l it but it keeps going throug MS's "who are you ,... what you running " thing but doesn'tr d/l ....
    : :
    : : Anyother way using ordinary VB ?
    : :
    : :
    : Not sure I undesrstand what you mean saing 'keeps going throug MS's "who are you ,... what you running " ' Do you have problem to download Script Control or some other problems?
    :
    :
    Sorry not getting back to you sooner. Been busy at work etc.

    I already have VB6 Enterprise edition so Script control is alrady on there. I hade a look at it and at the MSDN site but couldn't get my head round it.

    SO how does the script control work? And how can I use it to run one VBS at a time or one button to run them all?


  • :
    : : I tried to d/l it but it keeps going throug MS's "who are you ,... what you running " thing but doesn'tr d/l ....
    : :
    : : Anyother way using ordinary VB ?
    : :
    : :
    : Not sure I undesrstand what you mean saing 'keeps going throug MS's "who are you ,... what you running " ' Do you have problem to download Script Control or some other problems?
    :
    :
    Hi all,

    I have had a pop at this code and I wondered why I was getting errors.

    I have a number of VB Scripts that create webpages from a database. I want to be able to run them from a VB6 program.

    On my form I have the following:

    Command Button = cmdExecute1
    Drive box = Drive1
    Directory box = dir1
    File List Box = File1

    This is the code I have so far:
    [CODE]
    Option Explicit
    Dim PageMaker As String

    Private Sub File1_Click()

    PageMaker = File1.FileName

    End Sub



    Private Sub cmdExecute1_Click()

    On Error GoTo line1
    VBScript.AddCode PageMaker
    Exit Sub
    line1:
    MsgBox Err.Number & Err.Description, vbCritical, "error"
    Err.Clear
    End Sub

    Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    End Sub

    Private Sub Dir1_Change()
    File1.Path = Dir1.Path
    End Sub


    Private Sub Form_Load()
    Dir1.Path = App.Path
    File1.Path = App.Path

    End Sub

    [/CODE]

    What I am trying to do is click on a .vbs file and then click execute button and have it run (usually I double click the .vbs file and it creates a page).

    Where have I gone wrong ?

    Thanks for any help.


  • : What I am trying to do is click on a .vbs file and then click execute button and have it run (usually I double click the .vbs file and it creates a page).
    :
    : Where have I gone wrong ?
    :
    : Thanks for any help.
    :
    :
    :
    Here it is the link where you may found some code example
    http://www.vb-helper.com/howto_execute_vbscript.html
  • : One more link
    : http://www.devx.com/tips/Tip/14147
    :
    Thanks for the links ....

    I have got the VB side to run albeit it a bit on the strane side ... but it now comes up with a 1024 error everytime.

    I think that might be the script (VBS) itself. BUT when I double click the vbs script in a the window explorer it runs as normal.

    Any Ideas ?



  • : : One more link
    : : http://www.devx.com/tips/Tip/14147
    : :
    : Thanks for the links ....
    :
    : I have got the VB side to run albeit it a bit on the strane side ... but it now comes up with a 1024 error everytime.
    :
    :
    :
    I do not remember what that Error means. Do you habe any Error description?
  • : : : One more link
    : : : http://www.devx.com/tips/Tip/14147
    : : :
    : : Thanks for the links ....
    : :
    : : I have got the VB side to run albeit it a bit on the strane side ... but it now comes up with a 1024 error everytime.
    : :
    : :
    : :
    : I do not remember what that Error means. Do you habe any Error description?
    :
    Apparently the error is this "1024 Expected statement "




  • : : : : One more link
    : : : : http://www.devx.com/tips/Tip/14147
    : : : :
    : : : Thanks for the links ....
    : : :
    : : : I have got the VB side to run albeit it a bit on the strane side ... but it now comes up with a 1024 error everytime.
    : : :
    : : :
    : : :
    : : I do not remember what that Error means. Do you habe any Error description?
    : :
    : Apparently the error is this "1024 Expected statement "
    :
    OK that' better. Now we know some statement is missing. Could you post your code espacialy that line of code where compiler pointed the Error.
  • : : : : : One more link
    : : : : : http://www.devx.com/tips/Tip/14147
    : : : : :
    : : : : Thanks for the links ....
    : : : :
    : : : : I have got the VB side to run albeit it a bit on the strane side ... but it now comes up with a 1024 error everytime.
    : : : :
    : : : :
    : : : :
    : : : I do not remember what that Error means. Do you habe any Error description?
    : : :
    : : Apparently the error is this "1024 Expected statement "
    : :
    : OK that' better. Now we know some statement is missing. Could you post your code espacialy that line of code where compiler pointed the Error.
    :
    The VB code runs an this error is caught in the VB code
    VB CODE THUS;
    [CODE]
    Option Explicit
    Dim PageMaker As String
    Dim TempPageMaker As String

    Private Sub cmdExecute1_Click()

    ' Code that is missing is the code that assigned the file name to the string variable
    ' named TempPageMaker so the next code loads it in to text1.text

    TempPageMaker = FreeFile()
    Open App.Path & "unibondprem-script.vbs" For Input As #1 ' first open file"
    Do Until EOF(1)
    Line Input #1, TempPageMaker
    Text1.Text = Text1.Text & vbCrLf & TempPageMaker 'the words are added into the text box
    Loop
    Close #1

    'Add code that there is in text1
    On Error GoTo line1
    VBScript.AddCode (TempPageMaker)
    Exit Sub
    line1:
    MsgBox Err.Number & Err.Description, vbCritical, "error"
    Err.Clear

    End Sub

    [/CODE]

    The VBS Code;
    [CODE]
    Const ForReading = 1, ForWriting = 2
    strFilePath = "nplpd.html"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set ts = fs.OpenTextFile(strFilePath,ForWriting,True)
    ' open database
    set db = CreateObject("ADODB.Connection")
    db.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & mypath & "leaguedb.mdb")
    ' use SQL to select information
    sql = "SELECT data.team, data.website, data.address1, data.address2, data.address3, data.county, data.postcode, data.tel, data.fax FROM data WHERE league='nplpd';"
    set rs = db.Execute(sql)
    ' write the header
    ts.writeline ""
    ts.writeline ""
    ts.writeline ""
    ts.writeline ""
    ts.writeline "Ground-Hopper.co.uk - Northern Premier/Premier Div"
    ts.writeline ""
    ts.writeline ""
    ts.writeline " "
    ts.writeline "
    showMenus()
    "
    ts.writeline "

    "
    ts.writeline "

    Ground Hopper - Northern Premier League Premier Division

    "
    ts.writeline ""
    ts.writeline ""
    ts.writeline ""
    ts.writeline ""
    ts.writeline ""
    ts.writeline "
    Northern Premier League Premier Division
    SponsorUnibondimage
    Feeder to:Conference North
    Fed from:Northern Premier League Division 1
    "
    ts.writeline "

    "
    ' Address1Address3
    ' read resulting record set
    FirstLetter = 65
    do until rs.EOF

    ts.writeline ""
    rs.MoveNext
    loop

    ts.writeline "
    TeamWebsiteAddressCountyPostcodeTel.Fax.
    " & rs("Team") & "" & rs("website") & "" & RplBlank(rs("address1")) & "" & RplBlank(rs("address2")) & "" & RplBlank(rs("address3")) & "" & RplBlank(rs("county")) & "" & RplBlank(rs("postcode")) & "" & RplBlank(rs("tel")) & "" & RplBlank(rs("fax")) & "
    "
    ts.writeline ""
    ts.writeline ""
    ts.close

    Function RplBlank(FieldVal)

    if isnull(FieldVal) then
    RplBlank = " "
    else
    RplBlank = FieldVal
    end if

    End Function
    [/CODE]

    Thanks mate.


  • The VB code runs an this error is caught in the VB code
    : VB CODE THUS;
    : [CODE]
    : Option Explicit
    : Dim PageMaker As String
    : Dim TempPageMaker As String
    :
    : Private Sub cmdExecute1_Click()
    :
    : ' Code that is missing is the code that assigned the file name to the string variable
    : ' named TempPageMaker so the next code loads it in to text1.text
    :
    : TempPageMaker = FreeFile()
    : Open App.Path & "unibondprem-script.vbs" For Input As #1 ' first open file"
    : Do Until EOF(1)
    : Line Input #1, TempPageMaker
    : Text1.Text = Text1.Text & vbCrLf & TempPageMaker 'the words are added into the text box
    : Loop
    : Close #1
    :
    : 'Add code that there is in text1
    : On Error GoTo line1
    : VBScript.AddCode (TempPageMaker)
    : Exit Sub
    : line1:
    : MsgBox Err.Number & Err.Description, vbCritical, "error"
    : Err.Clear
    :
    : End Sub
    :
    : [/CODE]
    :
    What line of code caused problem? Usually, it's highligted by compilier
  • Hi

    The error is trapped in the error trap.

    the errror is in the VB Script by the look if it. But as it runs in the windows explorer when double clicked I wonder it the error is in the VB Scripts formatting?




  • : The error is trapped in the error trap.
    :
    Shut dawun On Error GoTo for a while and see what'll happen
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories