BuildStronglyTypedCollection()
functionregsvr32
registration; mention InnoSetupDemo2024
(Do not put spaces in the name)%tmp%\Demo2024\Demo2024.twinproj
%tmp%
Demo2024
Demo2024.twinproj
Next, let's customize the friendly name and description of our addin. This is the info that appears in the VBA Add-in Manager dialog box.
"DevCon 2024 Demo"
"Create a strongly-typed collection class from an existing VBA class object."
M:\Repos\NLS\DevCon2024\DevCon2024.accdb
Next, we're going to customize the controls that appear on the tool window. I'll explain what these controls will be used for in a minute. For now, all you need to know is that we are adding two text boxes, a command button, and a label to hold a version number.
tbObjName
Object Class Name
tbCollName
Collection Class Name
btnCreateClass
Create Collection Class
Timer1_Timer()
and HelloWorld_Click()
subroutinesPrivate Sub btnCreateClass_Click() MsgBox "Object class name: " & Me.tbObjName.Text & vbNewLine & _ "Collection class name: " & Me.tbCollName.Text, vbInformation, "Create Class" End Sub
oVehicle
for object class name and collVehicles
for collection class name then click [Create Collection Class]Now, let's talk about what this add-in will actually, you know, do.
The purpose of the add-in is to encapsulate the BuildStronglyTypedCollection()
function as described here: Strongly-Typed Collections: The Easy Way
I put a link to this article in the Resources page for today's presentation. If you've never heard of strongly-typed collection classes, I recommend you read up on them later.
For our purposes, the important thing to know about them is that you CANNOT build them in the VBA editor. They require setting a couple of hidden code attributes that only appear when you export the code module to a text file.
As you can imagine, manually jumping through those hoops is inefficient and error-prone. The existing code I wrote in VBA does automate the process, but it requires importing several additional dependencies. Our VBE add-in will be a direct replacement for the BuildStronglyTypedCollection()
function.
The following instructions assume you are building on a machine with 32-bit Office (mjw20), but installing on a machine with 64-bit Office (e.g., gbm18):
M:\Repos\NLS\DevCon2024\Build\DevCon2024_win64.dll
to %fb%\12114\DevCon2024_win64.dll
(I will test registering it tomorrow on gbm18)regsvr32 DevCon2024_win64.dll
Private Type RECT
structureGetClientRect()
function declareGetCurrentProcessId()
function declare line…Type UUID
structureSleep
sub declareCoCreateGuid
function declare and highlight the failure to compile due to the stricter typing of id As UUID
in WinDevLib versus id As Any
in my codeCoCreateGuid
function to show that explicit API declares override the WinDevLib versionsStrPtr()
from calls to FindWindowEx()
in InterProcess.callerApplicationObject 0&
to vbNullString
for calls to FindWindowEx()
in InterProcess.callerApplicationObject