Access - VBA
Send Email Via Groupwise
Submitted by Ken Puls on Fri, 2007-06-08 21:31. Excel - VBA | Access - VBA | General VBA & Programming | Novell Groupwise | Ppt - VBA | Pub - VBA | Word - VBAMacro Purpose:
- This is a stand-alone routine that will allow a user to automate the process of sending an email via the Novell Groupwise email client using VBA.
Examples of where this function shines:
- Assume that you want to email out a notifcation to a mailing list that you maintain in Excel or Access. This routine can be configured to send to one or more users at the same time, including one or more attachments.
Macro Weakness(es):
- Passing a file with commas in the filename will fail since arguments are passed to the function as a comma separated string.
Creating Your Own Constants For Functions
Submitted by Ken Puls on Wed, 2006-11-08 19:41. Excel - VBA | Access - VBA | General VBA & Programming | Outlook - VBA | Ppt - VBA | Pub - VBA | Word - VBAIntroduction:
One of the items that is very useful in code is the use of constants. These items are simply text masks that translate to numbers, making it easier for us to remember how to interact with the code.
For example, if you put "? vbOkOnly" in the immediate window, you'll see that it resolves to 0. Likewise, "? vbYes" resolves to 6. It's much easier to remember the words than the numbers, which is why Enumerations (or Enums) exist.
Creating your own Constants
The good news is that beginning with Excel 2000, we have been given the ability to program our own Enumerations to help in our coding!
Using Help in Your Applications
Submitted by Ken Puls on Sat, 2006-10-21 13:28. Excel - VBA | Access - VBA | General VBA & Programming | Outlook - VBA | Ppt - VBA | Pub - VBA | Word - VBAIntroduction:
One of the biggest parts lacking in user constructed solutions is documentation in the form of help files. As coders, we usually find it easier to build the application than explain to someone how to use it properly. After all, what we write in code is rarely read by others, and most novices think it's gibberish anyway. Actually explaining what you do in plain english (or whatever language you use) can be quite difficult. Ironically, it is this very fact that tells us why help files are important... write it down once, nicely, and you should never have to explain it again.
Printing Access Reports To A PDF File
Submitted by Ken Puls on Thu, 2006-09-28 18:30. Access - VBA | PDFIntroduction:
This article contains code examples to print a Microsoft Access report to a PDF file.
This code examples is built for PDFCreator, an open source PDF writer utility. Unlike Adobe Acrobat and CutePDF, which both require pro versions to create PDF's via code, PDFCreator is completely free! Download PDF Creator from Sourceforge here. Please note that this code will NOT work with Adobe Acrobat.
It should also be noted that this code example uses an Early Bind. If you are not familiar with the difference between Early and Late Binding, please read our article on Early vs Late binding.
Creating an Access Database (on the fly) Using VBA and SQL
Submitted by Ken Puls on Mon, 2006-09-04 20:22. Excel - ADO | Access - ADO | Access - VBA | General VBA & ProgrammingIntroduction:
I recently had reason to create a database on the fly if one did not exist. Since it took me some trial, error and searching (and then more trial and error,) I decided to share the method to do this. The following routine will create an Access database from any VBA enabled application, such as Word, Excel, Outlook, etc...
About the Example:
The example below creates a database at the root of the C: drive, using your MS Office Username. It also creates a new table "tblSample" with six fields in it. The most interesting part about this is that the code I provided below actually turns on the Unicode compression setting. Why is this important?
Controlling When Application Properties Are Toggled and Controlling Events
Submitted by Ken Puls on Fri, 2006-08-25 22:15. Excel - VBA | Access - VBA | General VBA & Programming | Outlook - VBA | Ppt - VBA | Pub - VBA | Word - VBAIntroduction:
This article actually covers two topics. The first is on controlling when application properties are toggled, and the second shows how to adapt that methodology into a superior method to manage events and prevent recursive calls. The first example set is purely based on Excel, but the methodology can be easily adpated to other applications. The second example is based on an userform and is not application specific.
Controlling When Application Properties Are Toggled:
I frequently have routines in Excel where I turn off ScreenUpdating, both to stop the flashing and speed up the code. The issue that I ran into is that I like to separate my code into reusable chunks. I didn't want to turn ScreenUpdating off/on in each routine, since the screen would then flash between routines, which ended up forcing me to write a wrapper for every function, in case I wanted to run in on it's own. This method takes care of that problem. I can write the ScreenUpdate into each chunk, and it will turn ScreenUpdates back on only if it was run standalone. This allows me to call as many routines as I want, nest them and more.
Retrieve Data From A Database To Excel Using SQL
Submitted by Ken Puls on Tue, 2006-04-11 23:00. Excel - ADO | Excel - SQL | Excel - VBA | Access - ADO | Access - SQL | Access - VBAMacro Purpose:
- Retrieve a recordset from a database and place it in an Excel worksheet, using an ADO connection to pass SQL strings.
Examples of where this function shines:
- Works well for retrieving data from Access (or other database management system) to Excel.
- Allows working with data in Excel, and making use of its rich features.
- Code is robust enough to support varying amounts of columns or rows in the recordset.
- You can supply your own SQL, allowing you to pull back only the data you need or want to work with.
Populate Multi-Column Listbox With Data From Access
Submitted by Ken Puls on Thu, 2006-02-16 00:00. Excel - ADO | Excel - SQL | Excel - VBA | Access - ADO | Access - SQL | Access - VBAMacro Purpose:
- Retrieves data from an Access database, and fills it into a userform listbox.
Examples of where this function shines:
- The Access database is in an Access 2000 format, but the code can be run from Excel 97-2003 with no issues.
Macro Weakness(es):
- Does not populate listbox with column header names.
- There is no error handling in this routine.
Versions Tested:
This function has been tested with Access & Excel 97, and Access & Excel 2003, and should also work with Access and Excel 2000 and 2002 (XP) without any modifications
Examples Of Using Late Binding To Connect To Other Applications
Submitted by Ken Puls on Thu, 2006-01-19 00:00. Excel - VBA | Access - VBA | Outlook - VBA | Ppt - VBA | Pub - VBA | Word - VBAIntroduction:
This article contains examples of using late binding to attach to the current instance or create a new instance of a variety of applications. It contains examples for creating the following from another application:
Please note that you can copy these code examples into any application that supports VBA, but the called application must be installed on your system for it to work. Just copy them into a standard module and run them. (No references need to be set in the Visual Basic Editor in order to make this code work.)
Connecting To/Creating A New Application Instance Via Late Binding
Submitted by Ken Puls on Sun, 2006-01-15 00:00. Excel - VBA | Access - VBA | Outlook - VBA | Ppt - VBA | Pub - VBA | Word - VBAIntroduction:
There are actually two different ways to accomplish this task, depending on exactly what you want to do. You can:
- Connect to an existing application (uses the GetObject method)
- Create a new application with no document loaded (uses the CreateObject method)
Please note that while all of this code was written to control Microsoft Word from Excel, you can use it in any other VBA enabled application, and you can also use it to control any other VBA enabled application, simply by changing "Word" to Excel, Powerpoint, Access, etc... in the examples below. For ready built examples, click here!


