Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Public variable

Hello,

I am setting up a public variable in the declaration section of my module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...

What am I doing wrong?

Thank you.

Eric


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Public variable

On Mar 17, 7:50 pm, "Eric" wrote:
Hello,

I am setting up a public variable in the declaration section of my module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...

What am I doing wrong?

Thank you.

Eric


Hello Eric,
The Auto_Open, Auto_Close, Auto_Activate, and Auto_Deactivate macros
are provided for backward compatability. You should be using
Workbook_Open instead of Auto_Open. Place your Public varaiable in the
Declarations section of ThisWorkbook and placce your Auto_Open code
in the Workbook_Open procedure.

Sincerely,
Leith Ross

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Public variable


Eric,
1. An Auto_Open sub must be in a standard module, not in the
ThisWorkbook module or a sheet module.
2. If you are opening the workbook using code then any Auto_xxx
subs will not run. Your have to use the RunAutoMacros method.
3. The public declaration of the variable should be in standard module.
4. The Workbook_Open event sub could also be used to initialize the variable.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Eric"
wrote in message
Hello,
I am setting up a public variable in the declaration section of my module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...
What am I doing wrong?
Thank you.
Eric


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Public variable

i don't have any luck when i have this in thisworkbook:
Option Explicit
Public RptFlag As Boolean
Public cnt As Long
Public iRow As Long
Public iMonth As Long
Public eMonth As Long

fails to compile because it says the variables aren't defined.
--


Gary


"Leith Ross" wrote in message
ups.com...
On Mar 17, 7:50 pm, "Eric" wrote:
Hello,

I am setting up a public variable in the declaration section of my module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...

What am I doing wrong?

Thank you.

Eric


Hello Eric,
The Auto_Open, Auto_Close, Auto_Activate, and Auto_Deactivate macros
are provided for backward compatability. You should be using
Workbook_Open instead of Auto_Open. Place your Public varaiable in the
Declarations section of ThisWorkbook and placce your Auto_Open code
in the Workbook_Open procedure.

Sincerely,
Leith Ross



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Public variable

Thank you Leith.

"Leith Ross" wrote in message
ups.com...
On Mar 17, 7:50 pm, "Eric" wrote:
Hello,

I am setting up a public variable in the declaration section of my

module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my

module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...

What am I doing wrong?

Thank you.

Eric


Hello Eric,
The Auto_Open, Auto_Close, Auto_Activate, and Auto_Deactivate macros
are provided for backward compatability. You should be using
Workbook_Open instead of Auto_Open. Place your Public varaiable in the
Declarations section of ThisWorkbook and placce your Auto_Open code
in the Workbook_Open procedure.

Sincerely,
Leith Ross





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Public variable

Thanks Jim, I got it to work...

"Jim Cone" wrote in message
...

Eric,
1. An Auto_Open sub must be in a standard module, not in the
ThisWorkbook module or a sheet module.
2. If you are opening the workbook using code then any Auto_xxx
subs will not run. Your have to use the RunAutoMacros method.
3. The public declaration of the variable should be in standard module.
4. The Workbook_Open event sub could also be used to initialize the

variable.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Eric"
wrote in message
Hello,
I am setting up a public variable in the declaration section of my module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my

module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...
What am I doing wrong?
Thank you.
Eric




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Public variable

I had this too...

Eric

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
i don't have any luck when i have this in thisworkbook:
Option Explicit
Public RptFlag As Boolean
Public cnt As Long
Public iRow As Long
Public iMonth As Long
Public eMonth As Long

fails to compile because it says the variables aren't defined.
--


Gary


"Leith Ross" wrote in message
ups.com...
On Mar 17, 7:50 pm, "Eric" wrote:
Hello,

I am setting up a public variable in the declaration section of my

module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my

module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows

the
variable empty...

What am I doing wrong?

Thank you.

Eric


Hello Eric,
The Auto_Open, Auto_Close, Auto_Activate, and Auto_Deactivate macros
are provided for backward compatability. You should be using
Workbook_Open instead of Auto_Open. Place your Public varaiable in the
Declarations section of ThisWorkbook and placce your Auto_Open code
in the Workbook_Open procedure.

Sincerely,
Leith Ross





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Public variable

Should be in a standard module, not ThisWorkbook.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
i don't have any luck when i have this in thisworkbook:
Option Explicit
Public RptFlag As Boolean
Public cnt As Long
Public iRow As Long
Public iMonth As Long
Public eMonth As Long

fails to compile because it says the variables aren't defined.
--


Gary


"Leith Ross" wrote in message
ups.com...
On Mar 17, 7:50 pm, "Eric" wrote:
Hello,

I am setting up a public variable in the declaration section of my
module
(Public Authorized_Machine as string)
I initialize the variable right in the Auto_open() sub expecting ths
variable and its value to be available to all the procedures in my
module,
but it does not work.
A simple "MsgBox Authorized_Machine" (in a seperate procedure) shows the
variable empty...

What am I doing wrong?

Thank you.

Eric


Hello Eric,
The Auto_Open, Auto_Close, Auto_Activate, and Auto_Deactivate macros
are provided for backward compatability. You should be using
Workbook_Open instead of Auto_Open. Place your Public varaiable in the
Declarations section of ThisWorkbook and placce your Auto_Open code
in the Workbook_Open procedure.

Sincerely,
Leith Ross





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
What is lifetime of public variable? John Wirt[_12_] Excel Programming 4 February 26th 06 04:27 PM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
Public/Procedure Variable Otto Moehrbach[_6_] Excel Programming 2 February 6th 04 04:58 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 08:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"