Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dave,
I have an access application which opens an new excel application in the background ( Set ExcelApp = New Excel.Application) and does it 'stuff' no problem, to keep down the code lines I have use the same 'Public Sub' proceedure with different values to get data from the excel spreadsheet in the background. The way to do this is to either (a) declare ExcelApp as a global variable, do the 'Public sub' doesn't need to set it to anything: Dim ExcelApp As Excel.Application Sub Caller() Set ExcelApp = New Excel.Application DoSomething ExcelApp End Sub Public Sub DoSomething() With ExcelApp.ActiveSheet ... End With End Sub Or pass the instance into the 'public sub': Sub Caller() Dim ExcelApp As Excel.Application Set ExcelApp = New Excel.Application DoSomething ExcelApp End Sub Public Sub DoSomething(ByRef ExcelApp As Excel.Application) With ExcelApp.ActiveSheet ... End With End Sub Regards Stephen Bullen Microsoft MVP - Excel www.oaltd.co.uk |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Possible to refer to a sheet's object name ? | Excel Worksheet Functions | |||
make camera object refer to dynamic range | Excel Discussion (Misc queries) | |||
How to refer to a cell format code? | Excel Discussion (Misc queries) | |||
refer to the sheets Name property in my code (not what is on the Tab) | Excel Programming | |||
Excel Object in VB when running under scheduler control | Excel Programming |