VBA – Shell.Application Deep Dive

In this installment … I thought I’d try and cover the wonderful world of the Shell.Application and illustrate some of its numerous capabilities:

 
Continue reading

VBA – Message Box That Supports Unicode Characters

Working on a recent project I needed to be able to use unicode characters in a Message Box. Sadly, the built-in MsgBox does not support such characters. Who knew?!

So I set off and quickly came across a Stack Overflow thread in which it was mentioned to use the MessageBoxW API. I then search it up and found:

 
Continue reading

VBA – WMI – Deleting A Printer

Just a short post today to demonstrate how easy it is to delete a printer from a PC executing some simple WMI code via VBA.

If you follow my blog at all, by now you are fully aware that WMI can easily retrieve information regarding pretty much any aspect of your PC: Hardware, Software, Events, …, but it can do so much more. Did you know it can also make changes to your PC! It can install, configure and even delete pretty much anything as well. So let’s explore a first simple example, the printer.

Continue reading

Access – Check If Anyone Has The Database Open

How can we tell if someone else has the database open?
 

Check for the Existence of a Lock File

In most cases, we should be able to check for the existence of a lock file (ldb or laccdb file). To do so we can use a function like the one presented in my article:

 

Now, in most scenarios, like 95+% of the time checking for the presence of a lock file is sufficient.  However, there is one scenario where a lock file will not be present and that is when someone already has it opened exclusively.

If a user opens a database with exclusive access (by clicking the arrow to the right of the Open button, and then clicking Open Exclusive), record locking is not used. Therefore, Microsoft Access doesn’t attempt to open or create a lock file. Microsoft

Therefore, looking for a lock file will not detect those instances when someone has the database open in Exclusive mode.

The instant you go to open a database file, that is already opened exclusively, you will receive an error message:

Could not use ‘FilePathAndName’; file already in use.

 
Continue reading

Access – VBA – Get The Next AutoNumber Value

Following up on my post:

I thought we could look at how we can determine the next AutoNumber Value that will be assign when a new entry is made in a table.
 
Continue reading

VBA – Universal RegEx Match Function

After yesterday’s post on how we can extract the MIME type from an HTML Img src attributes:

I thought that I’d show how we can slightly adapt the code to be universal.  Instead of creating one off functions for each and every scenario, how we can build a single function that we can use for all cases.
 
Continue reading

VBA – Early and Late Binding Declarations

In a continuation on the subject of Early and Late Binding:

I decided I should provide a few examples of going from Early to Late binding and vice versa and give the necessary VBA Reference Library for Early Binding …

These should be great starting points in knowing which Reference Libraries are required for which Early Binding declarations, and also aid anyone wanting to convert in either direction.

I hope this help a few of you!

These are the Examples provided thus far:

 
Continue reading

VBA – RegEx – Retrieve HTML Img Src MIME Type

I was working on some HTML automation recently and needed to extract the MIME type from an HTML Img Src Attribute value.

I could get into Left, Right, Mid, InStr, Len, …, but I thought I’d stretch my VBA RegEx legs a little and create a simple reusable function to do the job.

In case it can help anyone else out there, here it is!

Continue reading