IExcelClient::Initialize method

Initializes the Excel SOA client by creating a new instance of the ExcelDriver class to interact with the Excel workbook that is represented by the specified Microsoft.Office.Interop.Excel.Workbook object.

Syntax

HRESULT Initialize(
  [in] IUnknown *excelWorkbook,
  [in] Unknown  excelWorkbook
);
Function Initialize( _
  ByVal excelWorkbook As IUnknown, _
  ByVal excelWorkbook As Unknown _
) As HRESULT

Parameters

  • excelWorkbook [in]

    C++

    The Excel workbook for which the Excel SOA client should submit calculations to the HPC cluster.

    VB

    The Excel workbook for which the Excel SOA client should submit calculations to the HPC cluster.

Return value

C++

Returns S_OK unless an exception occurs.

Remarks

An exception can occur when you call the IExcelClient.Initialize method in PowerShell, because PowerShell does not correctly wrap the Workbook object that the Workbooks.Open method returns as an Microsoft.Office.Interop.Excel.Workbook type. To ensure that PowerShell provides a Workbook object to the IExcelClient.Initialize method, use the Type.GetTypeFromCLSID method to get the Microsoft.Office.Interop.Excel.WorkbookClass type, and create a wrapper of that type to pass to IExcelClient.Initialize.

The following example shows how to correctly create a wrapper for a workbook and pass it to the IExcelClient.Initialize method by using PowerShell.

# Open an Excel instance and open a workbook.
$excel = new-object -comobject Excel.Application
$excel.visible = $true
$workbook = $excel.Workbooks.Open( MyWorkbook.xlsm  )

# Get the workbook type using the class identifier (CLSID) for WorkbookClass.
$workbookType = [Type]::GetTypeFromCLSID("00020819-0000-0000-C000-000000000046")
$wrappedWorkbook = [System.Runtime.Interopservices.Marshal]::CreateWrapperOfType($workbook, $workbookType)

$excelclient = new-object -comobject Microsoft.Hpc.Excel.Com.ExcelClient
$excelclient.Initialize( $wrappedWorkbook )

Requirements

Product

HPC Pack 2008 R2 Client Utilities

Type library

Microsoft.Hpc.Excel.tlb

See also

IExcelClient