com addin excel - user switch sheet

R

Rene

Hi all,

the following code works fine:
(vb6 code for an com addin)
-
Dim ActiveSheet As Object
Dim ActiveFolder As Object

Set ActiveFolder = App.Workbooks(fileName)
Set ActiveSheet = ActiveFolder.Sheets("test")

ActiveSheet.Range("A1").Resize(number1, number2).Value = DataArray
ActiveSheet.Range("F1").Resize(number1, number2).Value = DataArray
-

but not if the user switch between the sheets!!!

How can I make it possible that the user can switch...

any ideas???
 
R

Rene

N

Nick Hebb

If you're using VB6, do not use App as a variable name for the
Excel.Application. App in VB6 refers to the VB6 Application - in this
case the COM DLL.

So you would want something like this:

Dim ws As Excel.Worksheet 'or Object for late binding
Set ws = gxlApp.ActiveSheet ' assumes gxlApp is a global variable
already set to Excel.Application

ws.Range("A1").Resize(number1, number2).Value = DataArray

HTH,

Nicholas Hebb
BreezeTree Software
http://www.breezetree.com
 
R

Rene

Hi.

Nick Hebb said:
If you're using VB6, do not use App as a variable name for the
Excel.Application. App in VB6 refers to the VB6 Application - in this
case the COM DLL.

So you would want something like this:

Dim ws As Excel.Worksheet 'or Object for late binding
Set ws = gxlApp.ActiveSheet ' assumes gxlApp is a global variable
already set to Excel.Application

ws.Range("A1").Resize(number1, number2).Value = DataArray

HTH,

Nicholas Hebb
BreezeTree Software
http://www.breezetree.com

I don´t use the keyword App. But the error still exist.
Err
Description "Anwendungs- oder objektdefinierter Fehler"
(in english: Application- or object Error)
HelpContext 1000095
HelpFile "C:\WINDOWS\Help\VBENLR98.CHM"
Number 50290

I don´t have the chm file...
 
R

Rene

Description "Application Defined or Object Defined Error"
sorry for my bad english ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top