' taken from Tutorial05.vbproj
'
' COMObject is the common base type for all objects in NetOffice which are based 
' on CoClasses or Interfaces
and also the type for anonymous COM Proxies at
' design time. This example shows you how to use.
' ' See chapter1 and chapter2 in technical documentation for further info. ' Private Sub Tutorial05Main() ' Initialize Api COMObject Support LateBindingApi.Core.Factory.Initialize() ' start application Dim application As New Excel.Application() application.DisplayAlerts = False Dim book As Excel.Workbook = application.Workbooks.Add() ' ActiveSheet is defined as unkown Proxy in Excel Type Library, it can
' have multiple times at runtime
but its always a COM Proxy, never a
' scalar type like bool or int.
' In VBA or PIA its converted to object, in NetOffice its represents
' as COMObject
. All NetOffice classes inherited COMObject Dim sheet As COMObject = application.ActiveSheet If (TypeName(sheet) = "Worksheet") Then Dim activeSheet As Excel.Worksheet = sheet End If '3 basic properties of COMObject Dim proxy As Object = sheet.UnderlyingObject Dim proxyClassName As String = sheet.UnderlyingTypeName Dim isDisposed As Boolean = sheet.IsDisposed application.Quit() application.Dispose() MessageBox.Show(Me, "Done!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub

 

   See next: Tutorial06 - Understand Variant Type

Last edited Jan 5, 2012 at 10:18 AM by SebastianDotNet, version 5