Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Global Variables Not Accessible

Hi:

I am trying to define two global variables, thus:

Public wbpath As String
Public timesheet As String

My problem is that this set of commands isn't executing. I set the values in auto_open
macro, and these two commands are right before the auto_open macro, but the value of
wbpath isnt recognized by subsequent macros.

Where should I put them to ensure that they execute at startup of the spreadsheet?

Thanks

John Baker
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Global Variables Not Accessible

John,

Are you declaring the variables in a standard code module? Do you
have Option Explicit at the top of every module? You should be
doing both these things.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"John Baker" wrote in message
...
Hi:

I am trying to define two global variables, thus:

Public wbpath As String
Public timesheet As String

My problem is that this set of commands isn't executing. I set

the values in auto_open
macro, and these two commands are right before the auto_open

macro, but the value of
wbpath isnt recognized by subsequent macros.

Where should I put them to ensure that they execute at startup

of the spreadsheet?

Thanks

John Baker



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Global Variables Not Accessible

Hi,

In standard module...like this.
if possible let us have your code.

Public wbpath As String

Sub Auto_open()
wbpath = "C:\Excel.xls"
'your code
End Sub

Regards,
Colo
http://www.interq.or.jp/sun/puremis/...astersLink.htm

"John Baker" wrote in message
...
Hi:

I am trying to define two global variables, thus:

Public wbpath As String
Public timesheet As String

My problem is that this set of commands isn't executing. I set the values

in auto_open
macro, and these two commands are right before the auto_open macro, but

the value of
wbpath isnt recognized by subsequent macros.

Where should I put them to ensure that they execute at startup of the

spreadsheet?

Thanks

John Baker


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Global Variables Not Accessible

The code looks like this:


Public wbpath As String
Public timesheet As String
Sub auto_open()
'
' auto_open Macro
' Macro recorded 11/25/2003 by John H Baker
'
wbpath = ActiveWorkbook.Path

timesheet = ActiveWorkbook.Name
'
Sheets("input").Select
Range("a1").Select


ChDir wbpath

End Sub

This module works fine, but others dont appear to pick up the variables.

Regards

John Baker

"Colo" wrote:

Hi,

In standard module...like this.
if possible let us have your code.

Public wbpath As String

Sub Auto_open()
wbpath = "C:\Excel.xls"
'your code
End Sub

Regards,
Colo
http://www.interq.or.jp/sun/puremis/...astersLink.htm

"John Baker" wrote in message
.. .
Hi:

I am trying to define two global variables, thus:

Public wbpath As String
Public timesheet As String

My problem is that this set of commands isn't executing. I set the values

in auto_open
macro, and these two commands are right before the auto_open macro, but

the value of
wbpath isnt recognized by subsequent macros.

Where should I put them to ensure that they execute at startup of the

spreadsheet?

Thanks

John Baker


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Global Variables Not Accessible

John,

If you edit the code after the variables are set, their values
will be reset. Perhaps this is the root of your problems.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"John Baker" wrote in message
...
The code looks like this:


Public wbpath As String
Public timesheet As String
Sub auto_open()
'
' auto_open Macro
' Macro recorded 11/25/2003 by John H Baker
'
wbpath = ActiveWorkbook.Path

timesheet = ActiveWorkbook.Name
'
Sheets("input").Select
Range("a1").Select


ChDir wbpath

End Sub

This module works fine, but others dont appear to pick up the

variables.

Regards

John Baker

"Colo" wrote:

Hi,

In standard module...like this.
if possible let us have your code.

Public wbpath As String

Sub Auto_open()
wbpath = "C:\Excel.xls"
'your code
End Sub

Regards,
Colo
http://www.interq.or.jp/sun/puremis/...astersLink.htm

"John Baker" wrote in message
.. .
Hi:

I am trying to define two global variables, thus:

Public wbpath As String
Public timesheet As String

My problem is that this set of commands isn't executing. I

set the values
in auto_open
macro, and these two commands are right before the auto_open

macro, but
the value of
wbpath isnt recognized by subsequent macros.

Where should I put them to ensure that they execute at

startup of the
spreadsheet?

Thanks

John Baker






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Global Variables Not Accessible

Chip:

Thanks, I think that's it.

In other words I need to close and restart after editing to make things work.

Makes sense.

Regards

John

"Chip Pearson" wrote:

John,

If you edit the code after the variables are set, their values
will be reset. Perhaps this is the root of your problems.


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
Why Would Add-In Modules Not Be Accessible? Edwin Kelly Excel Discussion (Misc queries) 2 June 23rd 09 06:11 PM
Columns not accessible JayDee Excel Worksheet Functions 3 December 15th 08 09:42 PM
The folder"name" isn't accessible AMM Excel Discussion (Misc queries) 5 March 3rd 05 11:01 PM
Custom Views Not Accessible Jerry B Excel Discussion (Misc queries) 0 January 26th 05 05:25 PM
Declaring Global Variables skmr3 Excel Programming 1 July 14th 03 05:54 AM


All times are GMT +1. The time now is 12:44 AM.

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

About Us

"It's about Microsoft Excel"