Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

3DEmbedded and VBA: Using 3DEmbedded in an Excel spreadsheet

Last post pe, elo 15 2008 15:32 by stabi. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • pe, elo 15 2008 15:32

    • stabi
    • Top 10 Contributor
    • Joined on pe, helmi 22 2008
    • Helsinki, Finland
    • Posts 32

    3DEmbedded and VBA: Using 3DEmbedded in an Excel spreadsheet

    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

    1. Select More controls from the Control toolbox.
    2. From the list, select "3DEmbedded window component".
    3. Click and drag to select a rectangular area in the spreadsheet to add the control.
    4. Click on the View Code tool button or select Tools->Macro->Visual Basic Editor from the menu to go to the Visual Basic editor.
    5. 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 

Page 1 of 1 (1 items)