I am struggling with references in my VBA project. In order to use my Drag and Drop function, I need to add the following reference to my workbook: Microsoft Windows Common Controls 6.0 (SP6)
. This reference has got the following location : C:\Windows\system32\MSCOMCTL.OCX
.
I would like to make sure that for any user using my specific workbook, the reference won't be missing. I have seen many tutorials about it and could "easily" add a reference, but I would like to understand precisely what I am doing and choose the best solution. I have several questions:
Late binding, Early Biding, AddFromFile, AddFromGUI
In those two topics (1 and 2), I read many things about references. The problem is I really do not know which option fits the best to my particular case.
My reference has already been added manually. Should I code something in order to be sure it is not missing when the code runs?
About adding a reference : Which option between those four is the best? I am hesitating between
AddFromFile
and Late Binding.Let's suppose I choose
AddFromFile
or Late Binding. I cannot manage toPrint
my reference's name! How do you know thatMicrosoft VBScript Regular Expressions 5.5
's.Name
isVBScript_RegExp_55
? I tried the code in this topic but it does not work (Must have done something wrong...).
"Universal" Path to my reference
I am very pessimistic and I was wondering: are references always stored at the same location? Let's suppose a user uses my specific workbook and hasn't got the reference it needs for the Drag and Drop function. He/She would need to add
MSCOMCTL.OCX
fromC:\Windows\system32\
.Are references always stored at the same location?
If not, how can I overcome that? Changing the path to something like the following?
Sub mySub() Dim sRef, sPath As String sRef = "MSCOMCTL.OCX" sPath = Environ("Windir") & "\system32\" & sRef End Sub
Thank you in advance for your answers and sorry if things are crystal clear and already answered in other posts, I may have missed it.