View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ShockWave[_3_] ShockWave[_3_] is offline
external usenet poster
 
Posts: 1
Default VB.Net DLL Using Excel Named Ranges

Hello and Help!

I have created a .Net DLL using the following in VB.Net:

Imports Excel
<ComClass(NameSpaceClass.ClassId, NameSpaceClass.InterfaceId
NameSpaceClass.EventsId) _
Public Class NameSpaceClass

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String
"DD3F5A18-99E3-4797-8004-B61A6013466F"
Public Const InterfaceId As String
"EB6EBB23-0528-48F9-AF68-7FD23B25FF10"
Public Const EventsId As String
"672CB2A1-C839-4157-97E7-EB73B430ADCB"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

'Dim ktfn As Excel.Range
Public Function showNum() As Single
showName
CType(xlApp.ActiveWorkbook.Application.Range("Exce lValue").Value
Single)
End Function
End Class


\VB.Net

Now I have also some code as follows in an Excel VBA Module:


Option Explicit
Option Base 1
Global ExcelValue As Range
Dim NameSpaceInstance As New NameSpacePlayer.NameSpaceClass


Function showNum() As Single
showNum = NameSpaceInstance .showNum
End Function

Function vbaNum() As Single
vbaNum = Range("ExcelValue").value
End Function

/VBA


what these two should do is return the value of a cell name
ExcelValue. ExcelValue can be any single cell such as A1 on Sheet1 o
B40 on Sheet 2...the cell name, ExcelValue, is global so that it can b
moved if needed without modifying any written code. With VBA this work
because of the integration between Excel and VBA but it has been
challenge getting my VB.Net COM DLL to get with the program.

Does anyone have any ideas

--
Message posted from http://www.ExcelForum.com