Category Archives: MS Excel

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

VBA – Find Disk Drive By Name

Once upon a time, I was asked to help automate a process of copying files to an External Drive. The issue was that when they plugged the device (external drive) into various machines, the associated drive letter wasn’t always the same. They also didn’t want me to use the Drive’s Serial Number as the identifier in case it died and they needed to replace it.

Instead, the solution was to bind to the Drive’s name. This way, if ever the drive was switched, all they needed to do was rename it in the same manner and the process would continue to work.

Now that we knew what we wanted to do, the question then became how could we do so?!
 
Continue reading

A More Modern Date Time Picker

In a recent discussion, someone asked if there were any more modern Date Time Pickers available to implement in their Microsoft Access database. Rightfully, as they stated, most current Date Time Pickers are very much visually stuck in the 80’s.

So I set out to tinker and see what was possible.

Continue reading

VBA – Debug.Print – spc, tab, semi-colon, comma and more

I think one of the most underutilized methods for developers is the Print method! Beyond which, those that do use it often don’t necessarily use it to its full potential.

Did You Know?
Did you know the Print method actually has parts (options) that you can use? Most developer don’t.
 

What Is The Print Method?

The print method allow us to output (or ‘print’) information/values/content to VBA/VBE the Immediate Window.
 

How Is That Useful?

I know developers that don’t see the utility of Print when they have MsgBox, but they serve 2 distinct purposes.

MsgBox is more for the end-user, to display a message to them. Sadly, you can interact with a MsgBox. Amongst other things, you can’t copy the contents.

Print is only for the developer as it is displayed in the VBE Immediate Window.  The beauty here is:

  • that you can copy/paste its content which is great to search up those error numbers/descriptions.
  • use it while in the VBE creating code without having to switch back and forth to the Access GUI and VBE windows
  • using the options, and other techniques, you can format the output.
  • you can sprinkle it throughout procedure to see the evolution of variables, … in real-time. This is great for debugging purposes.

 
Continue reading

VBA – Retrieve Windows SID And Username

In this article, I decided to play around with Windows SIDs and inversely the associated username.

It can be required, say when trying to look certain information up in the registry, to determine the SID of a Windows account. Or perhaps, inversely you have an SID and you’d like to know the Account Name it is associated with.
 
Continue reading

VBA – Determine Your PC’s MAC Address(es)

Last week I published a few functions to retrieve things like you Local IP & your Public IP address, you can learn all about it by reading:

Today, I thought I’d show you how easy it is to access another important Adapter property, the MAC Address(es).

All the examples I’ve seen always return a single value, but this can be incorrect depending on your setup! This is why I provide examples that return all the MAC addresses from your PC!
 
Continue reading

VBA – Determine Your PC’s IP Address

A while back I posted regarding retrieving the IP address of a host/domain:

 

Today, I thought I’d share a couple procedures to get information regarding the local PC’s IP addresses:

  • Local Network IP Addresses
  • Public IP Address

 
Continue reading

When A Macro Is NOT A Macro!?

I ask you:

When Is A Macro NOT A Macro!?

Always, and Never!

The first thing we need to ask is:

What is a Macro?

And that is a loaded questions, as it depends!  It depends on the application we are talking about!
 
Continue reading