Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB.Net DLL Using Excel Named Ranges
ShockWave wrote ...
I have created a .Net DLL <snip what these two should do is return the value of a cell named ExcelValue. Does anyone have any ideas? Consider using ADO.NET. Jamie. -- |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VB.Net DLL Using Excel Named Ranges
Yes, I've considered that but another thing to take note is that th
workbook is shared and I want the users be allowed to change its nam and location etc. With ADO.Net I'll have to code in where to make th connection. What it comes down to is, I need to somehow make the DLL know whic application it needs to be refering to. With MS Office Tools for VS.Ne 2003, there is such a qualifier called "ThisApplication" whereby wit it, I can just say "ThisApplication.Range("Whatever").Value" . BU here's the problem, I'm developing for Office 2002 and so can't use th nice tool set for VS.net. Still looking for help! Thanks -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 Named Ranges | Excel Discussion (Misc queries) | |||
How can I name worksheets in Excel according to named ranges? | Excel Worksheet Functions | |||
Accessing named ranges in Excel from VBA | Excel Discussion (Misc queries) | |||
Like 123, allow named ranges, and print named ranges | Excel Discussion (Misc queries) | |||
named ranges - changing ranges with month selected | Excel Programming |