views:

3493

answers:

6

Anyone have any suggestions for good books or even links? I was tasked with writing some things at work and they insist on using VBA and I am not very familiar with it.

EDIT

Identical to: http://stackoverflow.com/questions/483086/book-recommendation-for-visual-basic

Except this is visual basic and not VBA which are different. And there are only like 3 suggestions which are pretty old. I was looking for some more contemporary resources.

A: 

If you're already a developer (or even if you're not), I really liked Mastering VBA for Microsoft Office 2007. It was great for scripting some minor repetitive tasks.

John Feminella
+1  A: 

You have 'access-vba' in the tags for your post, so I assume you're going to be focused on using VBA with Access. You should clarify that, since VBA can be used with all of MSFT's office apps, but if you're only programming Access then you don't need to learn how VBA works with the others.

I learned VBA with Access by using this excellent book:

http://www.amazon.com/Beginning-Access-2000-Robert-Smith/dp/0764543830/ref=sr_1_2?ie=UTF8&s=books&qid=1238259950&sr=8-2

It's for Access 2000 and there've been some changes since then, but you can get a used copy for $3.50 so it would be well worth picking up as a resource. I thought it was an excellent guide for learning vba with access.

VBA is basically identical to Visual Basic 6, except that each of the MSFT Office apps has VBA and a VBA IDE embedded into it. A big part of programming the office apps is learning each application's object model. That doesn't necessarily have anything to do with VBA, you'd automate the app using same object model even if you were using C# or Delphi, but it's obviously important part of using VBA with the office app.

If you're doing general purpose office automation using two or more of the office apps, I expect the book J. Feminella suggested is a good one. If you're going to be working only in Access, I'd look for an entry level programming book for the specific version of Access you're using. Searching at Amazon and reading user comments would be good route to check, even if you get some specific recommendations in this thread.

Herbert Sitz
VBA is a SUPERSET of VB6 (from A2000 to A2003 (haven't checked for A2007), they use the same core VB6 DLL), and has substantial database-related enhancements to VB. The forms and controls are much richer than VB6 and have lots more events.
David-W-Fenton
@David W. Fenton: "VBA ... has substantial database-related enhancements to VB. The forms and controls are much richer than VB6 and have lots more events." -- huh?! VBA has no forms nor controls. VBA has no events. Go to your VBE's Object Browser, change the 'All Libraries' drop down to 'VBA', and tell me the "database-related enhancements" your seeing that I'm not. As Herbert Sitz said, "A big part of programming the office apps is learning each application's object model. That doesn't necessarily have anything to do with VBA".
onedaywhen
A: 

It will be helpful if you cite your version of Microsoft Access (2003,2007 etc.).

The Wrox publishing company produces excellent work. Be warned however that Access 2003 VBA (Cardoza et al, 2004, Wrox) completely skips the topic of arrays! There are other omissions as well, and the index is spotty. Access 97 VBA (Smith and Sussman, 1997, Wrox) is a good companion volume as it covers the information missing in the later book, and everything applies to Access 2003.

Links:

http://allenbrowne.com/tips.html

hwww.kayodeok.btinternet.co.uk/favorites/kbofficeaccesshowto.htm

Smandoli
+2  A: 

VBA won't help much if you do not master:

  • forms and controls events and properties
  • relational model and data integrity
  • SQL or at least Access queries

So you should start by learning those inside out (in interactive mode first), and do not hesitate to try them out, even with Access macros. After that, your VBA will be much simpler to write.

I see too often would-be-developers spending lots of time writing code to re-create functionalities that are already built in the product.

iDevlop
A: 

You should keep in mind before you go down this path the future of VBA. As of July 1, 2007 Microsoft stopped selling licenses for VBA to new customers. This means, in the future, no new applications will incorporated VBA (existing apps can continue to use it).

http://msdn.microsoft.com/en-us/isv/bb190538.aspx

Head on over to the VSTO (Visual Studio Tools for Office) blog to learn more about VBA's heir apparent: http://blogs.msdn.com/vsto/

VBA is, and will continue to be for some time, a valuable skill. If your situation allows, however, I'd consider jumping directly into the future.

MKing
A: 

In case you need to write VBA for Excel (which I do all the time), Writing Excel Macros by Steven Roman is excellent. It spends a lot of time discussing the Excel object model, which is what most Excel programming is about.

If you get through that book, and want more, Professional Excel Development is the next book to look at. It covers how to build applications, and why you want to keep your code in a separate worksheet from your data.

Curt