Learning VBA

I am in the process of learning VBA. As I gat more into this, I realize that there seem to be many different flavors of VBA out there.

Specifically, I am trying to learn VBA for MicroStation, A CAD program developed by Bentley. I am following a book titled:

"Learning MicroStation VBA", by Jerry Winters, 2006 Bentley Institute Press.

Over all it's a good book, but sometimes, it seems to be written for a reader that already knows VBA, which I do not.

I know the Bentley Program MicroStation very well, so when the VBA book references connecting to some bit of the program, I know pretty well whet it is talking about. However, it's the VBA I am having problems with, specifically when the book tells me to "Write some code", and I do, but it then does not offer any answers to the errors I get when I try the code out.

My Question is:

Is there some additional, fundamental VBA book or documentation I could reference to help me along in explaining what this book seems to be lacking in. I feel like I should know VBA better but when I look for additional information, it's always VBA for Excel or Word, or something else.

Thanks in advance
Who is Participating?
pony10usConnect With a Mentor Commented:
There is a forum at http://communities.bentley.com/communities/everything_else_community/f/289/t/47014.aspx that talks about errors in the book.
GrahamSkanConnect With a Mentor RetiredCommented:
The VBA language is consistent between applications.

However library differences between applications are inevitable. E.g There is no such thing as a WorkSheet (Excel) or a Slide(Powerpoint)Word.

In most Microsoft applications, while in the VBA IDE, you can add a reference to the particular application object library and then get access to the F1(Help) or the F2(Object browser)  for that particular application.
byundtConnect With a Mentor Commented:
VBA for Excel came first, and gradually spread out to the other Office applications, plus a handful of licensees. VBA was originally a subset of Visual Basic 3 (I believe), but features were swapped back and forth through Visual Basic 6. If you got a book for Visual Basic 6, that would probably fill in the missing gaps from your MicroStation VBA book. Excel 2003 had excellent on-line help for the VBA. Later versions have been reducing the amount of on-line help, and Excel 2013 got rid of it altogether, shunting users off to the MSDN website.

I find the most difficult part of coding in VBA to be wrapping your head around the object model for the application. Excel is based on ranges and worksheets where Word is based on paragraphs and sections. You absolutely have to start thinking in terms of the object model to get anywhere. If you approach Word VBA thinking in terms of words, sentences and pages there will be much gnashing of teeth, for example.

I urge you to use Option Explicit at the top of every module sheet. In Excel, there is a checkbox for it (Require variable declaration) in the VBA Editor under Tools...Options...Editor. Having done that, I then urge you to declare every variable that you use as something. Even though you can declare variables as Variant and avoid the need to exactly specify what you are dealing with--doing so will cause problems for you in debugging. Furthermore, by declaring a variable as something, you gain the advantage of IntelliSense to suggest the properties and methods available for your object.

One very common run-time error is "Subscript out of range". This usually means that the object in question doesn't exist yet, or that its name is spelled differently.
RKoonsAuthor Commented:
Thanks for your responses. I was especially rewarded to see in the forum that lots of people seem to be having issues with Chapter 5, which is the first chapter that has us doing code, and just happens to be a complete mess.

I will venture further out to see what else I can find to supplement this text and hope that chapter 6 is better.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.