Professional Documents
Culture Documents
How can I access Aspen InfoPlus.21 data via Excel VBA using Aspen SQLplus?
V9.0, V8.8, V8.7, V8.6, V8.5, V8.4, V8.3, V8.2, V8.1, V8.0, V7.3, V7.2, V7.1, 2006.5, 2006.0.3,
Version(s):
2006, 2004.2, 2004.1, 2004, 6.0.1
Problem Statement
This articles provides an example of an MS Excel Visual Basic (VB) script using Aspen SQLplus to access data from
Aspen Infoplus.21.
Solution
You will need to first configure an ODBC Data Source as shown in solution 121316.
Then you must add Microsoft ActiveX Data Objects 2.8 Library to Visual Basic Editor references under
Tools/References.
The example below shows a VB script that is behind a command button in an Excel spreadsheet that will execute a
query. You must change the HOST to your Aspen Infoplus.21 Server name and modify the query depending on the
application needs.
Option Explicit
Private rs As ADODB.Recordset
connect = True
Exit Function
Mal:
msgError = Err.Description
connect = False
End Function
https://support.aspentech.com/webteamcgi/SolutionDisplay_view.cgi?key=121625 Page 1 of 3
AspenTech Support Center Solution 121625 6/28/2016
rs.CursorLocation = adUseClient
Set rs.ActiveConnection = conn
Set execute = rs
Error = 0
Exit Function
Mal:
Error = Err.Number
msgError = Err.Description
Set rs = Nothing
Set execute = rs
End Function
If connect Then
sql = "select count(name) as quantity from ip_analogdef where name like 'fi%'"
Set rs = execute(sql)
Else
Cells(1, 1) = CLng(rs!quantity)
End If
conn.Close
Else
MsgBox msgError
End If
Cells(1, 1).Select
End Sub
Keywords
VBA script
SQLplus query
This document contains proprietary information of Aspen Technology, Inc. and is tendered subject to the condition that no copy or other
reproduction be made in whole or in part for use other than customer's internal use. Access to this document is strictly limited to customers
https://support.aspentech.com/webteamcgi/SolutionDisplay_view.cgi?key=121625 Page 2 of 3
AspenTech Support Center Solution 121625 6/28/2016
of Aspen Technology, Inc. who are registered users of the support web site; no access or further distribution to any third party, including
contractors or other agents of customer, is permitted. No use may be made of information herein except for which it is transmitted, without the
express prior written consent of Aspen Technology, Inc.
Aspen Technology may provide information regarding possible future product developments including new products, product features,
product interfaces, integration, design, architecture, etc. that may be represented as "product roadmaps." Any such information is for
discussion purposes only and does not constitute a commitment by Aspen Technology to do or deliver anything in these product roadmaps or
otherwise. Any such commitment must be explicitly set forth in a written contract between the customer and Aspen Technology, executed by
an authorized officer of each company.
https://support.aspentech.com/webteamcgi/SolutionDisplay_view.cgi?key=121625 Page 3 of 3