Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Option Explicit set at Application Level by Excel Add-in?

I am getting the errors normally associated with using undimensioned
variables in an Option Explicit module. But I haven't set Option
Explicit on that module nor anywhere else in my project (an Excel 2K3
workbook with some VBA routines).

If I dim the variables, the problem goes away.

So, I can work with it, but the problem is contrary to my understanding
of "Option Explicit".

My understanding is that "Option Explicit" only operates at module
level (says so in the Help file), but this I haven't done.

***Is it possible for a third party addin to somehow set "Option
Explicit" at the application level?

The reason I ask is that the only machine out of 11 which has the
problem is one which has a third party add-in installed. Some of the
add-in code is exposed and uses "Option Explicit", though, as expected,
on a per-module basis. Perhaps there is some code for the add-in that
I can't see.

***More generally, how can "Option Explicit" type dimensioning
requirements come to be in my module without my having set them?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Option Explicit set at Application Level by Excel Add-in?

Yes, Option Explicit is module level. However, I have never heard of a good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable Declaration,
which will add "Option Explicit" to all subsequently created modules, but
not existing ones.

NickHK

wrote in message
oups.com...
I am getting the errors normally associated with using undimensioned
variables in an Option Explicit module. But I haven't set Option
Explicit on that module nor anywhere else in my project (an Excel 2K3
workbook with some VBA routines).

If I dim the variables, the problem goes away.

So, I can work with it, but the problem is contrary to my understanding
of "Option Explicit".

My understanding is that "Option Explicit" only operates at module
level (says so in the Help file), but this I haven't done.

***Is it possible for a third party addin to somehow set "Option
Explicit" at the application level?

The reason I ask is that the only machine out of 11 which has the
problem is one which has a third party add-in installed. Some of the
add-in code is exposed and uses "Option Explicit", though, as expected,
on a per-module basis. Perhaps there is some code for the add-in that
I can't see.

***More generally, how can "Option Explicit" type dimensioning
requirements come to be in my module without my having set them?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Option Explicit set at Application Level by Excel Add-in?

Thanks Nick. Yep, it's not caused by that option as it isn't selected.

6 lines of code, 2 variables, acceptable time for completion. Simple
stuff. No burning need to dim those, other than this weird behaviour.
Also it's just slopping around with some test code before using it in
the real thing (it gets dimmed there), and don't want to have to dim
every variable as I introduce or delete it as it takes longer to finish
playing about with it.

You're right though, the need to not use Option Explicit is relatively
marginal.

Am mostly looking to solve the mystery or to discover if my Excel
installation is doing things that it shouldn't do.

NickHK wrote:
Yes, Option Explicit is module level. However, I have never heard of a good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable Declaration,
which will add "Option Explicit" to all subsequently created modules, but
not existing ones.

NickHK


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Option Explicit set at Application Level by Excel Add-in?

Well, if you do not have Option Explicit at the top of that module, I cannot
see how you would get :
"Compile Error
Variable not defined"

Any undefined variable would take its default value depending on its data
type.

NickHK

wrote in message
oups.com...
Thanks Nick. Yep, it's not caused by that option as it isn't selected.

6 lines of code, 2 variables, acceptable time for completion. Simple
stuff. No burning need to dim those, other than this weird behaviour.
Also it's just slopping around with some test code before using it in
the real thing (it gets dimmed there), and don't want to have to dim
every variable as I introduce or delete it as it takes longer to finish
playing about with it.

You're right though, the need to not use Option Explicit is relatively
marginal.

Am mostly looking to solve the mystery or to discover if my Excel
installation is doing things that it shouldn't do.

NickHK wrote:
Yes, Option Explicit is module level. However, I have never heard of a

good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable Declaration,
which will add "Option Explicit" to all subsequently created modules,

but
not existing ones.

NickHK




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Option Explicit set at Application Level by Excel Add-in?

"don't want to have to dim every variable as I introduce or delete it as it
takes longer to finish playing about with it"

And you don't find that it's too easy to mistype a variable name and get
unexpected results, if the lack of Option Explicit allows you to use an
undeclared variable?

For example, this sub will produce a message box with a value of zero rather
than ten, and it may take minutes to notice the misspelling.

Sub TestRange
Set MyRange = ActiveSheet.Range("A1:A10")
MsgBox MyRnage.Rows.Count
End Sub

This type of problem is eliminated if Option Explicit is used, as it will
detect the misspelled variable when the sub is compiled or first run.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
oups.com...
Thanks Nick. Yep, it's not caused by that option as it isn't selected.

6 lines of code, 2 variables, acceptable time for completion. Simple
stuff. No burning need to dim those, other than this weird behaviour.
Also it's just slopping around with some test code before using it in
the real thing (it gets dimmed there), and don't want to have to dim
every variable as I introduce or delete it as it takes longer to finish
playing about with it.

You're right though, the need to not use Option Explicit is relatively
marginal.

Am mostly looking to solve the mystery or to discover if my Excel
installation is doing things that it shouldn't do.

NickHK wrote:
Yes, Option Explicit is module level. However, I have never heard of a
good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable Declaration,
which will add "Option Explicit" to all subsequently created modules, but
not existing ones.

NickHK






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Option Explicit set at Application Level by Excel Add-in?

I understand your point Jon and it makes sense.

Horses for courses I guess. I can type 60WPM @ 99% accuracy. I type
code slower than that and rarely mistype things. I find
experimentation easier without Option Explicit. That's my experience.
Who knows, maybe I'm fooling myself... doesn't really matter.

Any ideas on why I might be getting those errors when not using Option
Explicit? It still seems mighty peculiar.

Jon Peltier wrote:
"don't want to have to dim every variable as I introduce or delete it as it
takes longer to finish playing about with it"

And you don't find that it's too easy to mistype a variable name and get
unexpected results, if the lack of Option Explicit allows you to use an
undeclared variable?

For example, this sub will produce a message box with a value of zero rather
than ten, and it may take minutes to notice the misspelling.

Sub TestRange
Set MyRange = ActiveSheet.Range("A1:A10")
MsgBox MyRnage.Rows.Count
End Sub

This type of problem is eliminated if Option Explicit is used, as it will
detect the misspelled variable when the sub is compiled or first run.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
oups.com...
Thanks Nick. Yep, it's not caused by that option as it isn't selected.

6 lines of code, 2 variables, acceptable time for completion. Simple
stuff. No burning need to dim those, other than this weird behaviour.
Also it's just slopping around with some test code before using it in
the real thing (it gets dimmed there), and don't want to have to dim
every variable as I introduce or delete it as it takes longer to finish
playing about with it.

You're right though, the need to not use Option Explicit is relatively
marginal.

Am mostly looking to solve the mystery or to discover if my Excel
installation is doing things that it shouldn't do.

NickHK wrote:
Yes, Option Explicit is module level. However, I have never heard of a
good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable Declaration,
which will add "Option Explicit" to all subsequently created modules, but
not existing ones.

NickHK



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Option Explicit set at Application Level by Excel Add-in?

Any ideas on why I might be getting those errors when not using Option
Explicit? It still seems mighty peculiar.


I have no suggestion for this, sorry.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
ups.com...
I understand your point Jon and it makes sense.

Horses for courses I guess. I can type 60WPM @ 99% accuracy. I type
code slower than that and rarely mistype things. I find
experimentation easier without Option Explicit. That's my experience.
Who knows, maybe I'm fooling myself... doesn't really matter.


Jon Peltier wrote:
"don't want to have to dim every variable as I introduce or delete it as
it
takes longer to finish playing about with it"

And you don't find that it's too easy to mistype a variable name and get
unexpected results, if the lack of Option Explicit allows you to use an
undeclared variable?

For example, this sub will produce a message box with a value of zero
rather
than ten, and it may take minutes to notice the misspelling.

Sub TestRange
Set MyRange = ActiveSheet.Range("A1:A10")
MsgBox MyRnage.Rows.Count
End Sub

This type of problem is eliminated if Option Explicit is used, as it will
detect the misspelled variable when the sub is compiled or first run.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
oups.com...
Thanks Nick. Yep, it's not caused by that option as it isn't selected.

6 lines of code, 2 variables, acceptable time for completion. Simple
stuff. No burning need to dim those, other than this weird behaviour.
Also it's just slopping around with some test code before using it in
the real thing (it gets dimmed there), and don't want to have to dim
every variable as I introduce or delete it as it takes longer to finish
playing about with it.

You're right though, the need to not use Option Explicit is relatively
marginal.

Am mostly looking to solve the mystery or to discover if my Excel
installation is doing things that it shouldn't do.

NickHK wrote:
Yes, Option Explicit is module level. However, I have never heard of a
good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable
Declaration,
which will add "Option Explicit" to all subsequently created modules,
but
not existing ones.

NickHK




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
Option Explicit [email protected] Excel Discussion (Misc queries) 5 April 30th 08 11:19 PM
option explicit Dave F Excel Discussion (Misc queries) 2 September 5th 06 02:46 PM
Option Explicit Piranha[_18_] Excel Programming 5 July 6th 05 04:18 AM
Option Commands (Option Explicit / Option Base etc) - Scope Alan Excel Programming 8 November 1st 04 02:22 AM
Option Explicit Grace[_4_] Excel Programming 6 June 12th 04 04:28 PM


All times are GMT +1. The time now is 12:12 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"