PC Review


Reply
Thread Tools Rate Thread

Can excel objects be defined as global variables

 
 
Phyllis
Guest
Posts: n/a
 
      5th Apr 2010
I want to define such items as
public ws as worksheet
public rg as range

I put them in the general declarations for "This Workbook". All other
variables such as integer, string etc. are behaving as global. But not the
objects. I read some discussion about defining them as I indicated above,
but when I go to another module, it gives me the error that the name is not
defined.
Can objects be global? If so, is there a certain place they have to be
defined
 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      5th Apr 2010
Define them in a normal Module and it should work fine.

RBS


"Phyllis" <(E-Mail Removed)> wrote in message
news:BB36320F-F0B3-4B84-A5FC-(E-Mail Removed)...
>I want to define such items as
> public ws as worksheet
> public rg as range
>
> I put them in the general declarations for "This Workbook". All other
> variables such as integer, string etc. are behaving as global. But not the
> objects. I read some discussion about defining them as I indicated above,
> but when I go to another module, it gives me the error that the name is
> not
> defined.
> Can objects be global? If so, is there a certain place they have to be
> defined


 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      5th Apr 2010
It has to be declared as a public variable:
http://www.cpearson.com/excel/TrulyGlobalVariables.htm

Here's some good insight into what ThisWorkbook is for:
http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

Normally, I use that for automating something on WorkBook_Open or
WorkBook_Close events.

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Phyllis" wrote:

> I want to define such items as
> public ws as worksheet
> public rg as range
>
> I put them in the general declarations for "This Workbook". All other
> variables such as integer, string etc. are behaving as global. But not the
> objects. I read some discussion about defining them as I indicated above,
> but when I go to another module, it gives me the error that the name is not
> defined.
> Can objects be global? If so, is there a certain place they have to be
> defined

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
initializing global variables when they are defined? =?Utf-8?B?d2F5bmVtYg==?= Microsoft Access VBA Modules 13 18th Oct 2005 04:52 PM
RE: initializing global variables when they are defined? =?Utf-8?B?d2F5bmVtYg==?= Microsoft Access VBA Modules 0 14th Oct 2005 05:18 AM
RE: initializing global variables when they are defined? =?Utf-8?B?d2F5bmVtYg==?= Microsoft Access VBA Modules 0 14th Oct 2005 05:18 AM
RE: initializing global variables when they are defined? =?Utf-8?B?T2Zlcg==?= Microsoft Access VBA Modules 0 14th Oct 2005 05:13 AM
Access to public variables defined in Global.asax.vb =?Utf-8?B?dnZlbms=?= Microsoft ASP .NET 2 10th Oct 2005 09:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 PM.