VB class to expose Excel methods? 
Author Message
 VB class to expose Excel methods?

I have created a class in VB6 to automate the creation and population of an
Excel spreadsheet; adding text, setting fonts etc:
    Dim MyXls as new ExcelRpt            - where ExcelRpt is my class

When I initialise the object the following is done:
'    cXls is dimmed as Worksheet
    Set cXlApp = New Excel.Application
    cXlApp.Workbooks.Add
    Set cXls = cXlApp.Workbooks(1).Worksheets(1)

Is it possible to expose all the Excel properties and methods of the
Worksheet used by my ExcelRpt class - cXLs - to MyXls object variable? If
so, how would I do this.

Currently, MyXls will only allow access to the properties and methods I have
added to the class. I want to be able to access all Excel Worksheet
properties and methods.

Thanks in advance,



Sat, 24 May 2003 03:00:00 GMT  
 VB class to expose Excel methods?


Fri, 19 Jun 1992 00:00:00 GMT  
 VB class to expose Excel methods?
Hi all,

I managed to solve it myself.

-Marcus


Quote:
> I have created a class in VB6 to automate the creation and population of
an
> Excel spreadsheet; adding text, setting fonts etc:
>     Dim MyXls as new ExcelRpt            - where ExcelRpt is my class

> When I initialise the object the following is done:
> '    cXls is dimmed as Worksheet
>     Set cXlApp = New Excel.Application
>     cXlApp.Workbooks.Add
>     Set cXls = cXlApp.Workbooks(1).Worksheets(1)

> Is it possible to expose all the Excel properties and methods of the
> Worksheet used by my ExcelRpt class - cXLs - to MyXls object variable? If
> so, how would I do this.

> Currently, MyXls will only allow access to the properties and methods I
have
> added to the class. I want to be able to access all Excel Worksheet
> properties and methods.

> Thanks in advance,



Sat, 24 May 2003 03:00:00 GMT  
 VB class to expose Excel methods?


Fri, 19 Jun 1992 00:00:00 GMT  
 VB class to expose Excel methods?
That is not possible in VB6. It will be in VB.NET since it supports
inheritance.



Quote:
>I have created a class in VB6 to automate the creation and population of an
>Excel spreadsheet; adding text, setting fonts etc:
>    Dim MyXls as new ExcelRpt            - where ExcelRpt is my class

>When I initialise the object the following is done:
>'    cXls is dimmed as Worksheet
>    Set cXlApp = New Excel.Application
>    cXlApp.Workbooks.Add
>    Set cXls = cXlApp.Workbooks(1).Worksheets(1)

>Is it possible to expose all the Excel properties and methods of the
>Worksheet used by my ExcelRpt class - cXLs - to MyXls object variable? If
>so, how would I do this.

>Currently, MyXls will only allow access to the properties and methods I have
>added to the class. I want to be able to access all Excel Worksheet
>properties and methods.

>Thanks in advance,



Wed, 11 Jun 2003 23:26:22 GMT  
 VB class to expose Excel methods?

This is absolutely possible in VB6. In fact, it is designed to do this.

In your class, create a 'Public Property Get' or a 'Public Function' that
returns the worksheet object (as an object)

    Public Property Get Xlsobj() As Object

        Set Xlsobj = cXls

    End Property

or

    Public Function GetXls() As Object

        Set GetXls = cXls

    End Function

In your main program you then code:

    Dim objXls As Object

    Set objXls = MyXls.Xlsobj

or

    Set objXls = MyXls.GetXls()

and voila, all the properties and methods of the worksheet object are
available via objXls.


Quote:
> That is not possible in VB6. It will be in VB.NET since it supports
> inheritance.



> >I have created a class in VB6 to automate the creation and population of
an
> >Excel spreadsheet; adding text, setting fonts etc:
> >    Dim MyXls as new ExcelRpt            - where ExcelRpt is my class

> >When I initialise the object the following is done:
> >'    cXls is dimmed as Worksheet
> >    Set cXlApp = New Excel.Application
> >    cXlApp.Workbooks.Add
> >    Set cXls = cXlApp.Workbooks(1).Worksheets(1)

> >Is it possible to expose all the Excel properties and methods of the
> >Worksheet used by my ExcelRpt class - cXLs - to MyXls object variable? If
> >so, how would I do this.

> >Currently, MyXls will only allow access to the properties and methods I
have
> >added to the class. I want to be able to access all Excel Worksheet
> >properties and methods.

> >Thanks in advance,



Thu, 12 Jun 2003 04:42:30 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Exposing Properties collection in custom classes as many MS Classes do

2. Exposing a Properties collection in custom classes as many MS Classes do

3. Exposing overloaded operator on C# class when used in VB.NET

4. Public Method in a class calling a private method in same class yields ByRef error

5. Exposing methods, VB vs VC

6. Only .GetType method is exposed in VB.NET (webbrowser control's document object)

7. Exposing classes from VC to VB and Variable arguments

8. How to call one VB class module method from another class in an ActiveX dll

9. exposing functions written in VB.NET to Excel

10. Exposing NEWENUM IUNKNOWN interface from a VBA Class mOdule

11. Exposing methods from .NET user control

12. Help, exposing DLL methods to external apps

 

 
Powered by phpBB® Forum Software