To Greg Maxey

A

aalaan

Hi

I much enjoy your postings and papers. I have two questions for you:

1) When I taught myself QuickBASIC many (!) years ago, I got used to the
concept of 'reserved words' ie words that did something and could not also
be set as variable names. There were a number of books explaining all the
functions of those reserved words. If you looked up 'Bloogs' and it wasn't
in the list then you could use it as you variable name. I can never find a
similar list of the 'reserved words' used in VBA. Will you (or someone)
point me at such a reference (preferably on-line)? Can I assume that for
example 'oStory' is an arbitrary variable name while 'StoryType' is not?

2 I often try to print out your papers for future reference (eg
'Installing Macros from Listings'). The right hand margin of the page always
gets trimmed off. I have this problem with most web pages and no-one has
been successful in telling me how to overcome it and why *some* websites
seem to avoid this.

TIA all.
 
G

Greg Maxey

aalaan,

Thanks for your comments.

I am afraid I don't have an answer to either of your questions. I
don't have any formal training in VBA, so what I know is just what I
have picked up along the way. A list of reserved works is not an arrow
in my quiver.

As for printing the tips pages, I just clicked on the "print this tip"
button on the bottom of a couple of the pages and they printed fine.

I don't know if it is your printer setting or perhaps an internet
setting. You might try one of the IE groups or perhaps an office
group.
 
J

Jonathan West

aalaan said:
Hi

I much enjoy your postings and papers. I have two questions for you:

1) When I taught myself QuickBASIC many (!) years ago, I got used to
the concept of 'reserved words' ie words that did something and could not
also be set as variable names. There were a number of books explaining all
the functions of those reserved words. If you looked up 'Bloogs' and it
wasn't in the list then you could use it as you variable name. I can never
find a similar list of the 'reserved words' used in VBA. Will you (or
someone) point me at such a reference (preferably on-line)? Can I assume
that for example 'oStory' is an arbitrary variable name while 'StoryType'
is not?

There is no such list, because every time you load up an external library,
you get different set of defined words. Sometimes the same word is used for
different purposes in different libraries. For instance, a Range object is a
quite different beast in Excel from the one you see in Word. VBA in Word
automatically loads the Word object model and VBA in Excel automatically
loads the Excel object model. (You can see this by going to Tools,
References in the VBA editor for each application.)

But even so, there are some general rules that you can follow with naming
conventions for variables which will leave you relatively safe. The first
and most obvious one you have already alluded to - if you apply a prefix to
your variable names then you are unlikely to trip up over a name in an
object library, because they tend not to be prefixed.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
K

Karl E. Peterson

aalaan said:
I can never find a similar list of the 'reserved
words' used in VBA. Will you (or someone) point me at such a
reference (preferably on-line)?

TextPad is a great little text editor, that supports custom language
definitions for syntax highlighting. Here's a page with a bunch of said
definitions, including numerous variations on VB (though, not specifically
VBA).

TextPad Syntax Definition Files U-Z
http://www.textpad.com/add-ons/synu2z.html
Can I assume that for example
'oStory' is an arbitrary variable name while 'StoryType' is not?

Why would you assume that?
2 I often try to print out your papers for future reference (eg
'Installing Macros from Listings'). The right hand margin of the page
always gets trimmed off. I have this problem with most web pages and
no-one has been successful in telling me how to overcome it and why
*some* websites seem to avoid this.

Switch to Firefox. Really. Life's way too short for such nonsense.
 
A

aalaan

Thanks for prompt reply. Is oStory some arbitrarily chosen variable word?
And re printing I have just been selecting CTRL-P. I'll try selecting the
print link. But why should they be different?
 
A

aalaan

Thanks. That TextPad thing is right over my head at present!

Karl E. Peterson said:
TextPad is a great little text editor, that supports custom language
definitions for syntax highlighting. Here's a page with a bunch of said
definitions, including numerous variations on VB (though, not specifically
VBA).

TextPad Syntax Definition Files U-Z
http://www.textpad.com/add-ons/synu2z.html


Why would you assume that?

But is it?
 
G

Greg Maxey

aalaan,

For me "oStory" is arbitrarily choosen. I suppose a purist would, and
justifiably, cringe at some of the variable names I use. They work for
me. When I am corrected enough times I will usually change.

I really have no clue why you are having problems with printing the
tips pages.
 
A

aalaan

Hi Greg

Just tried again and got the same result using the 'print these tips' link.
This has happened on a variety of machines and on Netscape as well as IE.
It's also happened with all printers. I cannot see what is wrong. Surely
this problem must be common? Someone suggested changing to Firefox but if
that was the only way out surely millions of IE users would be jumping up
and down. Anyone else with a suggestion or to point me at a suitable
newsgroup?
 
K

Karl E. Peterson

aalaan said:
Thanks. That TextPad thing is right over my head at present!

Okay then, just examine the SYN file within this:

http://www.textpad.com/add-ons/files/syntax/visual_basic.zip

That provides a fairly comprehensive list of the *language* keywords. As
Jonathan alluded, the object model contains numerous other "iffy" words that
you are free to recycle, but at your own peril.
But is it?

Not sure what you're asking? Neither is a reserved word in VB(A).
StoryType may indeed be used for something by something, but for the answer
to that the only way to really know is to pull up the Object Browser and do
a search.
 
J

Jonathan West

aalaan said:
Hi Greg

Just tried again and got the same result using the 'print these tips'
link. This has happened on a variety of machines and on Netscape as well
as IE. It's also happened with all printers. I cannot see what is wrong.
Surely this problem must be common? Someone suggested changing to Firefox
but if that was the only way out surely millions of IE users would be
jumping up and down. Anyone else with a suggestion or to point me at a
suitable newsgroup?

I suspect there is a mismatch between what IE thinks is the paper size of
your printer and that the printer is actually loaded with - in other words
IE and the printer driver think you have Letter, while in fact you are
loaded with A4. Check the settings and fix them.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jonathan West

Karl E. Peterson said:
Okay then, just examine the SYN file within this:

http://www.textpad.com/add-ons/files/syntax/visual_basic.zip

That provides a fairly comprehensive list of the *language* keywords. As
Jonathan alluded, the object model contains numerous other "iffy" words
that
you are free to recycle, but at your own peril.


Not sure what you're asking? Neither is a reserved word in VB(A).
StoryType may indeed be used for something by something, but for the
answer
to that the only way to really know is to pull up the Object Browser and
do
a search.

Few people make a distinction between words used in object names and words
that form part of the definition of the core VBA language. For the purpose
of aalaan's question it doesn't matter whether a word is an object name or
an original language keyword, since he needs to avoid re-using it in either
case.

And yes, StoryType is indeed a property of a Range object in the Word object
model.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jonathan West

Greg Maxey said:
aalaan,

For me "oStory" is arbitrarily choosen. I suppose a purist would, and
justifiably, cringe at some of the variable names I use. They work for
me. When I am corrected enough times I will usually change.


A common approach to using prefixes is to make the prefix indicate the type
of the variable you are using. So iCount would indicate an integer, dStart
would be a date, sName would be a string, oStory an object of some kind.

Some people get very sophisticated about this, for instance adding p for
parameters, so piCount would be an integer parameter passed to a function,
whereas iCount would be a local variable declared within the function.
Similarly g can be defined as global, so giCount would be an integer
variable declared using the Public keyword.

The m prefix is often used to declare module-level variables, so miCount
would be an integer declared using the Private keyword. The letter "a" can
indicate an array, so maiCount would be an array of integers declared using
the Private keyword!

If you want a more in-depth description of this, do a web search on
Hungarian Notation.

Note that the naming convention is entirely arbitrary. If you are writing
code for your own use, you can use all, some or none of what I have
describe - you do whatever works for making your code clear for you. There
is no single "right" way to do this. Any arbitrary system will be helpful so
long as it is consistently applied. Professional programmers working as a
team usually have some kind of common standard agreed or imposed, to make it
easier for team members to understand each others' code.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
K

Karl E. Peterson

Hi Jonathan --
Few people make a distinction between words used in object names and
words that form part of the definition of the core VBA language. For
the purpose of aalaan's question it doesn't matter whether a word is
an object name or an original language keyword, since he needs to
avoid re-using it in either case.

It's interesting, really. I know it's not a common practice, but it is one
that's good to know about. Now that you force me to think about it, I can
recall numerous times when I've over-ridden even VBA language functions with
my own. Dangerous as hell, but potentially useful at times.
And yes, StoryType is indeed a property of a Range object in the Word
object model.

Ah, sounded like it. I certainly would've had to query the ObjectBrowser to
be sure, though.

Thanks... Karl
 
A

aalaan

Thanks. I'm getting the hang of it, and I presume there is a list of
'reserved words' available somewhere (and surely not just by accessing the
object browser)?
 
A

aalaan

Thanks again. I can't understand why the other poster couldn't understand my
question. Seemed straightforward enough to me, and these answers from
Jonathan have put me on the right track.
 
A

aalaan

I've checked the printer driver and that's OK. I'll try to get into IE and
see what's up.
 
J

Jonathan West

aalaan said:
Thanks. I'm getting the hang of it, and I presume there is a list of
'reserved words' available somewhere (and surely not just by accessing the
object browser)?

That's what I was saying before - there isn't, because the list of reserved
words depends on what object libraries you happen to be using this week.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
P

Peter Jamieson

Actually I think this is probably a very common problem that has AFAIK only
been fixed in IE7. One problem is that when IE6 lays out the page, it
adjusts the page layout according to the page size (A4, Letter etc.) but
takes no notice of any margins you may have defined in IE File|Page Setup.
So, if for example, you prefer to leave a 2.5cm (c. 1in) margin on the left
so you can holepunch the page to put in a ringbinder, IE does the indent,
but does not alter the text width. Text and graphics are then truncated on
the right hand side. So you end up setting the margins to 0 and letting IE
change them to whatever it (or the printer driver) thinks the minimum
margins should be, and that usually works (but I suspect that in extreme
cases, even that may not work).

At least, that's what happens here. I guess most people never have a reason
to change their Page Setup settings which may be why the problem was not
regarded as serious enough to fix in IE6. You may be able to get around it
by using specialised features in your printer driver (e.g. size
reduction/centering) if that's the sort of problem you need to overcome. But
maybe your problem has another origin altogether.

Peter Jamieson
 
K

Karl E. Peterson

Peter said:
Actually I think this is probably a very common problem that has
AFAIK only been fixed in IE7.

Correction -- while it may be common in IE, it's never been a problem in
FireFox. HTH! ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top