## 3.14.11  SAPOpenWorkbook
You can use this API method to open an Analysis workbook. The workbook to be opened can be stored on a SAPBW server or on a BI platform.
The workbook is opened in the same Microsoft Excel instance. After the command execution, the opened workbook is active.
To call the method, use Application.Run and specify the following input parameters:
## · Name
Enter the technical name of the document.
For documents stored on a SAP BW server, this is the technical name as is it is shown in the Open dialog. For documents stored on a BI platform, it is the CUID that can be found in the general properties of an Analysis workbook in the CMC.
## · Formula Alias
Enter the formula alias for the data source or planning object, which provides the reference connection for the target workbook. The target workbook is the workbook that you want to open.
If the referenced connection is a local connection to a BW system, the workbook is opened from this system. If the referenced connection is a system (BW or HANA) on a BI platform, the workbook is opened from the BI platform.
This parameter is mandatory if several connections are used in the workbook, which provides the reference connection for the target workbook. If only one connection is used in the workbook, it is optional.
## · Parameters for variables
This parameter is only relevant if variables are used in the data source.
Enter the data source alias, the variable name and values.
The data source alias is only required if a variable is used in several data sources, the variables are not merged and you want to specify different values for the same variable.
There are three methods for entering the variable name and values:
- Enter one parameter, for example "[DS\_1]0COUNTRY=France, 0PRODUCT=P01, [DS\_2]0COUNTRY=Germany" .
- Enter several parameters, for example "[DS\_1]0COUNTRY", "France", "[DS\_1]0PRODUCT", "P01", "[DS\_2]0COUNTRY", "Germany" .
- Enter a mixture of both: one parameter per variable/value combination, for example "[DS\_1]0COUNTRY=France", "0PRODUCT=P01", "[DS\_2]0COUNTRY=Germany"
Limitations:
The first method only allows single members as variable values, complex input strings are not allowed.
As the Microsoft Excel command Application.Run is limited to 30 arguments, the second and third method only allow you to enter 14 variable or 28 value combinations.
If you need to set more than 28 variable/value combinations with a complex input string (for example, multiple members separated by a semicolon), the third method can be changed to specify multiple variables in one string. In this case the data source alias is mandatory but can be left blank, for example "[DS\_1]0COUNTRY=France", "[]0PRODUCT=P01, P02, P03,[DS\_2]0COUNTRY=Germany" .
The system returns one of the following output parameters for each command execution:
- 0 = execution failed.
- 1 = execution successful.
## Example
Dim lResult as long lResult = Application.Run("SAPOpenWorkbook", "TEST\_OpenWB", "DS\_1", "0COUNTRY", "France")
With this example, the workbook TEST\_OpenWB is opened from the system of data source DS\_1. The variable 0COUNTRY is set to value France.
## Related Information
Syntax for Entering Values [page 140]