<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Run a procedure with parameters with VBscript in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45121#M11875</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I want to run a procedure with a vbscript. Sas is able to generate the code to run it but my procedure contains parameters that are prompted when the proc is runned manually (these parameters are needed in some queries).&lt;BR /&gt;
&lt;BR /&gt;
Unfortunatly when the script runs, the parameters are not prompt.&lt;BR /&gt;
I can prompt informations from the script but I don't know how to run the procedure with this informations as parameters for the procedure.&lt;BR /&gt;
&lt;BR /&gt;
Here is my code :&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Dim app         ' As SASEGuide.Application&lt;BR /&gt;
dim a ' as integer&lt;BR /&gt;
dim b ' as integer&lt;BR /&gt;
dim c ' as integer&lt;BR /&gt;
&lt;BR /&gt;
a= InputBox("Jour")&lt;BR /&gt;
b= InputBox("Mois")&lt;BR /&gt;
c= InputBox("Année")&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Call dowork (a,b,c)&lt;BR /&gt;
&lt;BR /&gt;
'shut down the app&lt;BR /&gt;
If not (app Is Nothing) Then&lt;BR /&gt;
    app.Quit&lt;BR /&gt;
    Set app = Nothing&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub dowork(a,b,c)&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    '----&lt;BR /&gt;
    ' Start up Enterprise Guide using the project name&lt;BR /&gt;
    '----&lt;BR /&gt;
    Dim prjName     ' As String&lt;BR /&gt;
    Dim prjObject   ' As SASEGuide.Project&lt;BR /&gt;
    Dim containerName     ' As String&lt;BR /&gt;
    Dim containerObject   ' As SASEGuide.Container&lt;BR /&gt;
    Dim containerColl     ' As SASEGuide.ContainerCollection&lt;BR /&gt;
    Dim annee ' As integer&lt;BR /&gt;
    Dim mois' As integer&lt;BR /&gt;
    Dim jour' As integer&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
    prjName = "\\xxxxxxxxx.egp" ' Project Name&lt;BR /&gt;
    containerName = "Flux de processus" ' Container Name&lt;BR /&gt;
      &lt;BR /&gt;
    Set app = CreateObject("SASEGObjectModel.Application.4")&lt;BR /&gt;
    If Checkerror("CreateObject") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Set prjObject = app.Open(prjName,"")&lt;BR /&gt;
    If Checkerror("App.Open") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
        &lt;BR /&gt;
    '-----&lt;BR /&gt;
    'Get The Container Collection and Object&lt;BR /&gt;
    '-----    &lt;BR /&gt;
    Set containerColl = prjObject.ContainerCollection&lt;BR /&gt;
    If Checkerror("Project.ContainerCollection") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Dim i       ' As Long&lt;BR /&gt;
    Dim count   ' As Long&lt;BR /&gt;
    count = containerColl.count&lt;BR /&gt;
    For i = 0 To count&lt;BR /&gt;
        Set containerObject = containerColl.Item(i)&lt;BR /&gt;
        If Checkerror("ContainerCollection.Item") = True Then&lt;BR /&gt;
            Exit Sub&lt;BR /&gt;
        End If&lt;BR /&gt;
        &lt;BR /&gt;
        If (containerObject.Name = containerName) Then&lt;BR /&gt;
            Exit For&lt;BR /&gt;
        Else&lt;BR /&gt;
            Set containerObject = Nothing&lt;BR /&gt;
        End If&lt;BR /&gt;
&lt;BR /&gt;
    Next &lt;BR /&gt;
    &lt;BR /&gt;
    If not (containerObject Is Nothing) Then&lt;BR /&gt;
        '----&lt;BR /&gt;
        ' Run the Container&lt;BR /&gt;
        '----&lt;BR /&gt;
        containerObject.Run &lt;BR /&gt;
        If Checkerror("Container.Run") = True Then&lt;BR /&gt;
            Exit Sub&lt;BR /&gt;
        End If               &lt;BR /&gt;
    End If&lt;BR /&gt;
                &lt;BR /&gt;
    '-----&lt;BR /&gt;
    ' Save the new project&lt;BR /&gt;
    '-----&lt;BR /&gt;
    prjObject.Save&lt;BR /&gt;
    If Checkerror("Project.Save") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    '-----&lt;BR /&gt;
    ' Close the project&lt;BR /&gt;
    '-----&lt;BR /&gt;
    prjObject.Close&lt;BR /&gt;
    If Checkerror("Project.Close") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
       &lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function Checkerror(fnName)&lt;BR /&gt;
    Checkerror = False&lt;BR /&gt;
    &lt;BR /&gt;
    Dim strmsg      ' As String&lt;BR /&gt;
    Dim errNum      ' As Long&lt;BR /&gt;
    &lt;BR /&gt;
    If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        strmsg = "Error #" &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; "In Function " &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description&lt;BR /&gt;
        'MsgBox strmsg  'Uncomment this line if you want to be notified via MessageBox of Errors in the script.&lt;BR /&gt;
        Checkerror = True&lt;BR /&gt;
    End If&lt;BR /&gt;
         &lt;BR /&gt;
End Function&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your help&lt;BR /&gt;
&lt;BR /&gt;
Georges</description>
    <pubDate>Mon, 06 Dec 2010 18:09:49 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-12-06T18:09:49Z</dc:date>
    <item>
      <title>Run a procedure with parameters with VBscript</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45121#M11875</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I want to run a procedure with a vbscript. Sas is able to generate the code to run it but my procedure contains parameters that are prompted when the proc is runned manually (these parameters are needed in some queries).&lt;BR /&gt;
&lt;BR /&gt;
Unfortunatly when the script runs, the parameters are not prompt.&lt;BR /&gt;
I can prompt informations from the script but I don't know how to run the procedure with this informations as parameters for the procedure.&lt;BR /&gt;
&lt;BR /&gt;
Here is my code :&lt;BR /&gt;
&lt;B&gt;&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Dim app         ' As SASEGuide.Application&lt;BR /&gt;
dim a ' as integer&lt;BR /&gt;
dim b ' as integer&lt;BR /&gt;
dim c ' as integer&lt;BR /&gt;
&lt;BR /&gt;
a= InputBox("Jour")&lt;BR /&gt;
b= InputBox("Mois")&lt;BR /&gt;
c= InputBox("Année")&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Call dowork (a,b,c)&lt;BR /&gt;
&lt;BR /&gt;
'shut down the app&lt;BR /&gt;
If not (app Is Nothing) Then&lt;BR /&gt;
    app.Quit&lt;BR /&gt;
    Set app = Nothing&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub dowork(a,b,c)&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    '----&lt;BR /&gt;
    ' Start up Enterprise Guide using the project name&lt;BR /&gt;
    '----&lt;BR /&gt;
    Dim prjName     ' As String&lt;BR /&gt;
    Dim prjObject   ' As SASEGuide.Project&lt;BR /&gt;
    Dim containerName     ' As String&lt;BR /&gt;
    Dim containerObject   ' As SASEGuide.Container&lt;BR /&gt;
    Dim containerColl     ' As SASEGuide.ContainerCollection&lt;BR /&gt;
    Dim annee ' As integer&lt;BR /&gt;
    Dim mois' As integer&lt;BR /&gt;
    Dim jour' As integer&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
    prjName = "\\xxxxxxxxx.egp" ' Project Name&lt;BR /&gt;
    containerName = "Flux de processus" ' Container Name&lt;BR /&gt;
      &lt;BR /&gt;
    Set app = CreateObject("SASEGObjectModel.Application.4")&lt;BR /&gt;
    If Checkerror("CreateObject") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Set prjObject = app.Open(prjName,"")&lt;BR /&gt;
    If Checkerror("App.Open") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
        &lt;BR /&gt;
    '-----&lt;BR /&gt;
    'Get The Container Collection and Object&lt;BR /&gt;
    '-----    &lt;BR /&gt;
    Set containerColl = prjObject.ContainerCollection&lt;BR /&gt;
    If Checkerror("Project.ContainerCollection") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Dim i       ' As Long&lt;BR /&gt;
    Dim count   ' As Long&lt;BR /&gt;
    count = containerColl.count&lt;BR /&gt;
    For i = 0 To count&lt;BR /&gt;
        Set containerObject = containerColl.Item(i)&lt;BR /&gt;
        If Checkerror("ContainerCollection.Item") = True Then&lt;BR /&gt;
            Exit Sub&lt;BR /&gt;
        End If&lt;BR /&gt;
        &lt;BR /&gt;
        If (containerObject.Name = containerName) Then&lt;BR /&gt;
            Exit For&lt;BR /&gt;
        Else&lt;BR /&gt;
            Set containerObject = Nothing&lt;BR /&gt;
        End If&lt;BR /&gt;
&lt;BR /&gt;
    Next &lt;BR /&gt;
    &lt;BR /&gt;
    If not (containerObject Is Nothing) Then&lt;BR /&gt;
        '----&lt;BR /&gt;
        ' Run the Container&lt;BR /&gt;
        '----&lt;BR /&gt;
        containerObject.Run &lt;BR /&gt;
        If Checkerror("Container.Run") = True Then&lt;BR /&gt;
            Exit Sub&lt;BR /&gt;
        End If               &lt;BR /&gt;
    End If&lt;BR /&gt;
                &lt;BR /&gt;
    '-----&lt;BR /&gt;
    ' Save the new project&lt;BR /&gt;
    '-----&lt;BR /&gt;
    prjObject.Save&lt;BR /&gt;
    If Checkerror("Project.Save") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    '-----&lt;BR /&gt;
    ' Close the project&lt;BR /&gt;
    '-----&lt;BR /&gt;
    prjObject.Close&lt;BR /&gt;
    If Checkerror("Project.Close") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
       &lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function Checkerror(fnName)&lt;BR /&gt;
    Checkerror = False&lt;BR /&gt;
    &lt;BR /&gt;
    Dim strmsg      ' As String&lt;BR /&gt;
    Dim errNum      ' As Long&lt;BR /&gt;
    &lt;BR /&gt;
    If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        strmsg = "Error #" &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; "In Function " &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description&lt;BR /&gt;
        'MsgBox strmsg  'Uncomment this line if you want to be notified via MessageBox of Errors in the script.&lt;BR /&gt;
        Checkerror = True&lt;BR /&gt;
    End If&lt;BR /&gt;
         &lt;BR /&gt;
End Function&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your help&lt;BR /&gt;
&lt;BR /&gt;
Georges</description>
      <pubDate>Mon, 06 Dec 2010 18:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45121#M11875</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-12-06T18:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Run a procedure with parameters with VBscript</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45122#M11876</link>
      <description>Hi:&lt;BR /&gt;
  It looks like SAS Enterprise Guide or an EG Project is involved in this VBScript. You might want to post this question in the EG Forum, since most of the folks who use VB and EG and the main developer who knows about automation with VB and .NET hang out over there.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 06 Dec 2010 18:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45122#M11876</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-06T18:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run a procedure with parameters with VBscript</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45123#M11877</link>
      <description>Thanks,&lt;BR /&gt;
&lt;BR /&gt;
I'll do it right away</description>
      <pubDate>Tue, 07 Dec 2010 09:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Run-a-procedure-with-parameters-with-VBscript/m-p/45123#M11877</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-12-07T09:24:59Z</dc:date>
    </item>
  </channel>
</rss>

