[mso] Re: Declaring "Global" Variable?

  • From: "4Groups" <4groups@xxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Wed, 2 Feb 2005 13:31:59 -0500

Jim,
Thanks for helping... Still Not working ... I think it's because the
starting Marco is in a Sheet Object and the rest are in a module.... I did
add the Option Explicit but not the Option Compare XXX - What does the xxx
stand for??? Is that my problem??

-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf
Of Jim Pettit
Sent: Wednesday, February 02, 2005 2:55 PM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: Declaring "Global" Variable?

April--

It's all about scope. And I don't mean the mouthwash ;-)

Declare the variable outside the scope of the 'StartCleanMRICKReg'
subroutine.

If, as I think you're talking about, you want the variable to be available
in just those subroutines in the module containing the 'StartCleanMRICKReg'
subroutine, you can place this line at the top of the module (under the
'Option Compare XXX' and 'Option Explicit' lines, if they exist):

Dim MyMacro As String

You can then assign a value to that variable there, or in any subroutine in
that module.

If, on the other hand, you'd like that variable to be available anywhere in
the application -- that is, from any procedure in any other modules --
declare it as a Public variable by placing the following line at the top of
that module (or any other) again beneath the 'Option Compare XXX' and
'Option Explicit' lines, if they exist:

Public MyMacro As String

You can then assign a value to that variable there, or in any subroutine in
that module, or in any subroutine in any module on the application.

Hope I didn't confuse you too much...

--Jim

-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf
Of 4Groups
Sent: Wednesday, February 02, 2005 8:01 AM
To: 'Office'
Subject: [mso] Declaring "Global" Variable?

I have an active x Control in File A ... when you click on it it runs the
following "Sheet1" Excel Object Macro:
 
Private Sub StartCleanMRICKReg_Click()
Dim MyStartFile
 
    MyStartFile = InputBox("What is the name of the file to run macro on? IE
Book1")
    Windows(MyStartFile & ".xls").Activate
 
    MyMacro = "NoAccountNumbers"
    Application.Run "CleanMRIExport"
 
End Sub
As you see it set the value for the variable MyMacro.... How do I declare it
so that the value of the variable is still there when the application runs
the CleanMRIExport script that is located in the same file as Module1??
 
April



*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx
with the word "unsubscribe" (without the quotes) in the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx
with the word "unsubscribe" (without the quotes) in the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: