Abstract
This article describes how to access the vcCOM interface in 3DEmbedded using VBA in Excel 2003.
Overview
Excel's Visual Basic for Applications uses late binding through IDispatch to access objects embedded in a spreadsheet. These objects also have some Excel-specific properties added to them. This means that the Application property in the vcc3DEmbedded control cannot be accessed directly.
The solution is to explicitly assign the control to a variable of type vccEmbeddedWindow, and access the Application property through that variable.
Embedding 3DEmbedded in a spreadsheet
- Select More controls from the Control toolbox.
- From the list, select "3DEmbedded window component".
- Click and drag to select a rectangular area in the spreadsheet to add the control.
- Click on the View Code tool button or select Tools->Macro->Visual Basic Editor from the menu to go to the Visual Basic editor.
- From the Tools menu, select References, and make sure the Visual Components COM Library is checked.
Accessing the IvcApplication object
In the code, to access the IvcApplication object of 3DEmbedded, type the following:
Dim vcw As vccEmbeddedWindow
Dim vcapp As IvcApplication
Set vcw = vccEmbeddedWindow1
If vcw.ActivationState = AS_Activated Then
Set vcapp = vcw.Application
' use vcapp here
Else
' 3DEmbedded is not activated
End If
Example Excel file
This file requires 3DEmbedded to be installed: framevisibility.xls