Desktop productivity for business analysts and programmers

running EG projecvt using VBscript

Reply
N/A
Posts: 0

running EG projecvt using VBscript

Hello, everybody. Sorry for my terrible english in advance. I hope, you'll help find me find out, what am i doing wrong)

I have a project, which i want to run by schedule. EG created default VBscript (Tools->Schedule Project how it was written in manual).

Option Explicit
Dim app

Call dowork

'shut down the app
If not (app Is Nothing) Then
app.Quit
Set app = Nothing
End If


Sub dowork()
On Error Resume Next
'----
' Start up Enterprise Guide using the project name
'----
Dim prjName
Dim prjObject

prjName = "C:\SAS\sending_test.egp" 'Project Name

Set app = CreateObject("SASEGObjectModel.Application.4")
If Checkerror("CreateObject") = True Then
Exit Sub
End If

'-----
' open the project
'-----
Set prjObject = app.Open(prjName,"")
If Checkerror("app.Open") = True Then
Exit Sub
End If


'-----
' run the project
'-----
prjObject.run
If Checkerror("Project.run") = True Then
Exit Sub
End If


'-----
' Save the new project
'-----
prjObject.Save
If Checkerror("Project.Save") = True Then
Exit Sub
End If

'-----
' Close the project
'-----
prjObject.Close
If Checkerror("Project.Close") = True Then
Exit Sub
End If

End Sub

Function Checkerror(fnName)
Checkerror = False

Dim strmsg
Dim errNum

If Err.Number <> 0 Then
strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Checkerror = True
End If

End Function


When i' m trying to run this script, nothing happens!

I tried to delete error check from my script, ones again run it and recieved th message from Windows Script Host: Unable to connect to server: SASMain.
So to run project i'm forced to push the button "run branch from .... task", then enter login and password to connect to server! Is it possible to correct my script so, that connection to server and running of my tasks occurs automatic?

Thank you!
N/A
Posts: 0

Re: running EG projecvt using VBscript

Hi Tano,

Have you seen this SAS-Note?: http://support.sas.com/techsup/unotes/SN/014/014700.html
In the bottom you'll find a link to the OLE Automation Guide, which is the engine for EG Scheduling.

Anyhow, I do not know anything about Visual Basic programming, so I'll just assume that you wrote everything right; what I do know is that to schedule an EG project you should create (if EG doesn't do it for you), an Scheduled Task in Windows Control Panel.

Identify the task that corresponds to your Project and set the USERID & PASSWORD you'll use in there. If you're working on a remote SAS server, make sure that your UserId starts with the Windows Domain. i.e. domain\userid.

PS: If you double-click on the task and it doesn't run immediatly, it means that there's something wrong with the code.

Cheers
Ask a Question
Discussion stats
  • 1 reply
  • 604 views
  • 0 likes
  • 1 in conversation