How to round a number to a five cents multiple in VB/A

In switzerland, we like rounding monetary numbers to 2 decimal places, with multiples of 5 for the fractional part. This is (probably) because our (physical) money has no “cent” coins, but we have 5 cents coins. That’s commonly called “5 cents” rounding. Example: 1.6777777 becomes 1.70 1.4444444 becomes 1.45 1.0333333 becomes 1.05 and so on.… Continue reading How to round a number to a five cents multiple in VB/A

How to measure any text with Word, vba code included

If you’re trying to put up a nice document template with Microsoft Word® you’ll probably have to precisely position different elements of your composition. When these elements are text, it may help to know precisely how much space you need to preserve for their layout. Sometimes, this can even be tricky. My previous post is the starting… Continue reading How to measure any text with Word, vba code included

How do I compute the length of the longest text for a date in Word ?

A Word document to compute the length of the longest text for a date in Word. Working on the layout of a Microsoft Word French and English versions of a document template with a customer, we were trying to determine where to position a tab, so that we had the document date appear on the… Continue reading How do I compute the length of the longest text for a date in Word ?

Tracking active directory user logon/off for the just cause – Part 1

Doing some work remotely, typically using a VPN to access our customer(s) network, or some other type of remote access software (like TeamViewer) is unavoidable when we’re maintaining our customers infrastructures. The recurring problem I encounter and that initially got me started on tracking user logons and logoffs is to determine a convenient moment where… Continue reading Tracking active directory user logon/off for the just cause – Part 1

A pure (windows) “C” version of urlencode

This is a windows pure C language version of a urlencode() function.Sometimes, when I need simple tools and self contained windows EXEs (“just run it”, no “dll”s to copy or register), I find it simpler to code in C than in other languages. Particularly when you want to link with specialized libraries available only in… Continue reading A pure (windows) “C” version of urlencode

Using the free zip library in VBA

In a previous post I briefly explained how you can compile the free zlib library with Visual 2013 Studio and produce a 32 and a 64 bits dll that you can then use in VBA (Word, Excel, Access, etc…). If you follow this link to the article, you can even download the binaries I baked.… Continue reading Using the free zip library in VBA

How to get the same result in VBA and in PHP computing a CCITT CRC checksum

I was working last week on a Microsoft Access application and I needed to get some data from a webserver running Apache/PHP. Exchanging data with the server was easy, the WinHTTP and XML ActiveX library components are really cool and easy to use for that. But then I came unto some unexpected trouble when I… Continue reading How to get the same result in VBA and in PHP computing a CCITT CRC checksum

Share the Clipboard with VBA and the Windows API

Accessing the clipboard in Windows becomes quite tricky in VBA, particularly if you have to stay 32 and 64 bits compatible. Here’s my compilation of portable routines, inspired by MSDN, Internet scraping and good sense. First the Declares section (I know, it pours out of the frame on the right, just select and copy the… Continue reading Share the Clipboard with VBA and the Windows API

Microsoft Access Databases ADO connection strings for 32/64 bits

If you try to open a connection to an Access database via ADO, you’ll have to use a different provider, whether you’re coding for 32 or 64 bits environments. Here’s a utility function I use for that (updated 25.02.2014):

Of course you have to have the correct jet engine files installed on the target… Continue reading Microsoft Access Databases ADO connection strings for 32/64 bits

Compiling the zlib compression library with Visual Studio 2013

I you need zip compression in your development project, the zlib library is a good and free solution. There’s however a bit of googling necessary to achieve a successful compilation with VS2013, especially for generating the 32 bits version of the library. As I just needed it for some VB/VBA integration, I had to sort… Continue reading Compiling the zlib compression library with Visual Studio 2013