[COLOR=green]'"Microsoft ActiveX Data Objects 2.5 Library" and
'"SAS: Integrated Object Model (IOM) 1.0 Type Library" and
'"SASWorkSpaceManager 1.0 Type Library"[/color]
Dim obWS As SAS.Workspace
Dim obWSM As New SASWorkspaceManager.WorkspaceManager
[COLOR=green]'Code from web site [/color][URL unfurl="true"]http://www.ratcliffe.co.uk/note_colon/note07.htm[/URL]
Sub Form_Load()
Dim obConn As New ADODB.Connection
Dim obRS As New ADODB.Recordset
Dim errorString As String
[COLOR=green]'start the SAS session
[/color]Set obWS = obWSM.Workspaces.CreateWorkspaceByServer("Local", _
VisibilityProcess, Nothing, "", "", errorString)
[COLOR=green]'submit some SAS code
[/color]obWS.LanguageService.Submit _
"data a; do x=1 to 10; y=10*x; output; end; run;"
[COLOR=green]'open an ADO connection to the data set
[/color]Dim connString As String
connString = "provider=sas.iomprovider.1; SAS Workspace ID=" _
+ obWS.UniqueIdentifier
obConn.Open connString
obRS.Open "work.a", obConn, adOpenStatic, adLockReadOnly, _
adCmdTableDirect
[COLOR=green]'write the table as html (visible in Word with tags)
[/color]obRS.MoveFirst
Dim sTable As String
sTable = "<TABLE BORDER=0><TBODY><TR><TD class=Data>"
Selection.TypeText sTable
sTable = obRS.GetString(, , "</TD><TD class=Data>", _
"</TD></TR><TR><TD class=Data>")
Selection.TypeText sTable
sTable = "</TD></TR></TBODY></TABLE>"
Selection.TypeText sTable
[COLOR=green]'tidy-up [/color]
obRS.Close
obConn.Close
obWS.Close
End Sub