Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

To Greg Maxey

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aalaan - 29 Nov 2006 18:56 GMT
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.
Greg Maxey - 29 Nov 2006 19:32 GMT
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.

> Hi
>
[quoted text clipped - 16 lines]
>
> TIA all.
aalaan - 29 Nov 2006 19:57 GMT
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?

> aalaan,
>
[quoted text clipped - 37 lines]
>>
>> TIA all.
Greg Maxey - 29 Nov 2006 20:03 GMT
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.

> 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
[quoted text clipped - 41 lines]
> >>
> >> TIA all.
aalaan - 29 Nov 2006 20:12 GMT
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?

> aalaan,
>
[quoted text clipped - 58 lines]
>> >>
>> >> TIA all.
Jonathan West - 29 Nov 2006 20:33 GMT
> Hi Greg
>
[quoted text clipped - 5 lines]
> 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.

Signature

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

aalaan - 30 Nov 2006 01:05 GMT
I've checked the printer driver and that's OK. I'll try to get into IE and
see what's up.

>> Hi Greg
>>
[quoted text clipped - 10 lines]
> IE and the printer driver think you have Letter, while in fact you are
> loaded with A4. Check the settings and fix them.
aalaan - 30 Nov 2006 01:15 GMT
That didn't work.

> I've checked the printer driver and that's OK. I'll try to get into IE and
> see what's up.
[quoted text clipped - 13 lines]
>> words IE and the printer driver think you have Letter, while in fact you
>> are loaded with A4. Check the settings and fix them.
Peter Jamieson - 30 Nov 2006 12:32 GMT
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
> That didn't work.
>
[quoted text clipped - 15 lines]
>>> words IE and the printer driver think you have Letter, while in fact you
>>> are loaded with A4. Check the settings and fix them.
Karl E. Peterson - 30 Nov 2006 17:34 GMT
> 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!  ;-)
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 30 Nov 2006 17:50 GMT
Thanks for this. I do indeed set a fairly big left margin and will try the
effect of reducing that.

> 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,
[quoted text clipped - 35 lines]
>>>> words IE and the printer driver think you have Letter, while in fact
>>>> you are loaded with A4. Check the settings and fix them.
aalaan - 30 Nov 2006 18:18 GMT
That did not work. But it appears I have now found the solution, though
*why* it is a solution escapes me. I simply change page setup to 'letter'
although in the printer I am using A4. Surely this is a bug and workaround?
The system arrogantly assumes everyone in the World is using the US 'letter'
although A4 is pretty well internationally standard.

> Thanks for this. I do indeed set a fairly big left margin and will try the
> effect of reducing that.
[quoted text clipped - 38 lines]
>>>>> 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.
Jonathan West - 29 Nov 2006 20:48 GMT
> 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.

Signature

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

aalaan - 30 Nov 2006 01:02 GMT
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)?

>> aalaan,
>>
[quoted text clipped - 28 lines]
> a team usually have some kind of common standard agreed or imposed, to
> make it easier for team members to understand each others' code.
Jonathan West - 30 Nov 2006 08:57 GMT
> 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.

Signature

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

aalaan - 30 Nov 2006 17:49 GMT
Thanks for bearing with me. The vb6 (learning edition) that I'm using is
from a CD where surely there is a 'standard' object library. How can it
change each week?

>> 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
[quoted text clipped - 4 lines]
> reserved
> words depends on what object libraries you happen to be using this week.
Karl E. Peterson - 30 Nov 2006 18:15 GMT
> Thanks for bearing with me. The vb6 (learning edition) that I'm using
> is from a CD where surely there is a 'standard' object library.

Have you ever pressed the F2 key?

> How can it change each week?

It changes in reaction to your changes in the Project-References dialog,
which (for sake of completeness) are saved with each project.
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 30 Nov 2006 18:24 GMT
OK. So I can then allocate any variable name that isn't revealed by that?

>> Thanks for bearing with me. The vb6 (learning edition) that I'm using
>> is from a CD where surely there is a 'standard' object library.
[quoted text clipped - 5 lines]
> It changes in reaction to your changes in the Project-References dialog,
> which (for sake of completeness) are saved with each project.
Jonathan West - 30 Nov 2006 19:22 GMT
Yes.

Signature

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

> OK. So I can then allocate any variable name that isn't revealed by that?
>
[quoted text clipped - 7 lines]
>> It changes in reaction to your changes in the Project-References dialog,
>> which (for sake of completeness) are saved with each project.
Jonathan West - 29 Nov 2006 19:42 GMT
> Hi
>
[quoted text clipped - 9 lines]
> 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.

Signature

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

Karl E. Peterson - 29 Nov 2006 19:47 GMT
> 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.
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 29 Nov 2006 20:00 GMT
Thanks. That TextPad thing is right over my head at present!

>> I can never find a similar list of the 'reserved
>> words' used in VBA. Will you (or someone) point me at such a
[quoted text clipped - 12 lines]
>
> Why would you assume that?

But is it?
Karl E. Peterson - 29 Nov 2006 20:30 GMT
> 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.

>>> Can I assume that for example
>>> 'oStory' is an arbitrary variable name while 'StoryType' is not?
>>
>> Why would you assume that?
>
> 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.
Signature

Working without a .NET?
http://classicvb.org/

Jonathan West - 29 Nov 2006 20:36 GMT
>> Thanks. That TextPad thing is right over my head at present!
>
[quoted text clipped - 20 lines]
> 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.

Signature

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

Karl E. Peterson - 29 Nov 2006 23:10 GMT
Hi Jonathan --

>> That provides a fairly comprehensive list of the *language*
>> keywords.  As Jonathan alluded, the object model contains numerous
[quoted text clipped - 19 lines]
> 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
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 30 Nov 2006 01:04 GMT
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.

>>> Thanks. That TextPad thing is right over my head at present!
>>
[quoted text clipped - 29 lines]
> And yes, StoryType is indeed a property of a Range object in the Word
> object model.
Karl E. Peterson - 30 Nov 2006 17:39 GMT
> 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.

I understood your question, but I wonder if you did. <g>  You referenced
QuickBasic, which had a *very* rigid system of reserved keywords.  VB(A)
doesn't.  You can override nearly all of them, as you wish.  You may get
burned in the process, but that's the consequence of power.  There are
keywords in VB proper that cannot be overridden, but they can probably be
counted on a few hands.  The rest are fair game.

I did tell you how to determine whether a given word was "in use" by other
components within your project sphere, too, btw.
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 30 Nov 2006 17:54 GMT
OK getting this a bit better. The key is your contrast of QB with VBA and
yes, the former was channelling my thinking. With regard to the last part of
your post, would you please repeat that as I can't find it?

Also, suppose you are deliberately going to avoid overriding *any* keyword.
Where will you then find the list?

>> Thanks again. I can't understand why the other poster couldn't
>> understand my question. Seemed straightforward enough to me, and
[quoted text clipped - 9 lines]
> I did tell you how to determine whether a given word was "in use" by other
> components within your project sphere, too, btw.
Karl E. Peterson - 30 Nov 2006 18:20 GMT
> OK getting this a bit better. The key is your contrast of QB with VBA

Just to muddy the waters a bit more.  I have been assuming you were working
with VBA all along, since that's the charter of this group, but in your
other recent post you reference VB6.  VBA is part of VB6, but there is more.
It's important to be *very* specific in discussions like this, to avoid
folks like me introducing even more uncertainty into your world.

> and yes, the former was channelling my thinking. With regard to the
> last part of your post, would you please repeat that as I can't find
> it?
>
> Also, suppose you are deliberately going to avoid overriding *any*
> keyword. Where will you then find the list?

Okay, the answer to both of these questions is the "Object Browser".  You
can get to it via either the View menu in the IDE, or by pressing the F2
key.  Within the object browser, you'll see a dropdown that defaults to
"<All Libraries>".  Searches automatically include every library you
reference (Project-References).  You can examine individual libraries by
selecting them from that top dropdown.
Signature

Working without a .NET?
http://classicvb.org/

>>> Thanks again. I can't understand why the other poster couldn't
>>> understand my question. Seemed straightforward enough to me, and
[quoted text clipped - 13 lines]
>> Working without a .NET?
>> http://classicvb.org/
aalaan - 30 Nov 2006 20:03 GMT
Thanks. Working with vb6 *and* vba (and these seem to be mostly the same?)

>> OK getting this a bit better. The key is your contrast of QB with VBA
>
[quoted text clipped - 36 lines]
>>> Working without a .NET?
>>> http://classicvb.org/
Karl E. Peterson - 30 Nov 2006 21:02 GMT
> Thanks. Working with vb6 *and* vba (and these seem to be mostly the
> same?)

Mostly yeah.  I typically say VBA is a subset of VB6, but in this forum
them's considered "shootin' words." <g>
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 01 Dec 2006 00:41 GMT
Karl (BTW sorry to keep quoting your name Greg, but the thread lives on...).
I tried the fawcette archives and got a 'you're not a member- go away' type
message!

>> Thanks. Working with vb6 *and* vba (and these seem to be mostly the
>> same?)
>
> Mostly yeah.  I typically say VBA is a subset of VB6, but in this forum
> them's considered "shootin' words." <g>
Karl E. Peterson - 01 Dec 2006 18:56 GMT
> Karl (BTW sorry to keep quoting your name Greg, but the thread lives
> on...).

NP.

> I tried the fawcette archives and got a 'you're not a member-
> go away' type message!

Oh those...  I forget that some of them are "protected"...  Ever hear of
BugMeNot?  http://www.bugmenot.com/

(If you were using FireFox, I'd recommend their extension -- login at all
kinds of places with a simple right-click!)
Signature

Working without a .NET?
http://classicvb.org/

aalaan - 30 Nov 2006 18:20 GMT
I think what is needed is a text explaining how to convert your thinking
from the procedural and rigid framework of say QuickBASIC to this different
way of thinking.

> OK getting this a bit better. The key is your contrast of QB with VBA and
> yes, the former was channelling my thinking. With regard to the last part
[quoted text clipped - 17 lines]
>> other
>> components within your project sphere, too, btw.
Karl E. Peterson - 30 Nov 2006 18:38 GMT
> I think what is needed is a text explaining how to convert your
> thinking from the procedural and rigid framework of say QuickBASIC to
> this different way of thinking.

You might try browsing the archives (BasicPro, VBPJ) here:

http://www.fawcette.com/archives/magazines/vsm/

In particular, go back to the early-90s.  For example, the "First
Impressions of Visual Basic" article in the June/July 1991 issue.
Signature

Working without a .NET?
http://classicvb.org/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.