I'm still having issues with an Excel spreadsheet with macro's...
to make it multi-compatible for Office & Windows versions.
In particular for ADODB in 'Microsoft Active X Data Object #.# Library' (C:\Program Files\Common Files\System\ado\msado*.dll) & mscomct2.ocx.
I developed it in 2010 & am using it in my 2007 without problems (using 6.0 Library), however a work colleague uses 2007 & has a different version (2.8 Library) installed & it keeps failing.
I've been comparing GUID's but appears there are many different GUID's for each different 'Microsoft Active X Data Object #.# Library' ...
Extracts only:
The AddFromGuid wont work in this instance unless I code for all the possible GUID's for ADODB.
Same goes for AddFromFile as filename can be different too
(eg: msado15.dll or msado20.dll):
C:\Program Files\Common Files\System\ado\msado*.dll
to make it multi-compatible for Office & Windows versions.
In particular for ADODB in 'Microsoft Active X Data Object #.# Library' (C:\Program Files\Common Files\System\ado\msado*.dll) & mscomct2.ocx.
I developed it in 2010 & am using it in my 2007 without problems (using 6.0 Library), however a work colleague uses 2007 & has a different version (2.8 Library) installed & it keeps failing.
I've been comparing GUID's but appears there are many different GUID's for each different 'Microsoft Active X Data Object #.# Library' ...
Extracts only:
Rich (BB code):
For Each chkRef In vbProj.References
n = n + 1
sName = chkRef.Name
sFile = chkRef.FullPath
sFullPath = chkRef.FullPath
sDescr = chkRef.Description
sGuid = chkRef.GUID
' set sName, sFile & sDescr based on current library/reference
' this is beneficial for non installed libraries as name, descr & fullpath will be blank
If chkRef.GUID = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}" Then
sName = "MSComCtl2"
sFile = "mscomct2.ocx"
sDescr = "Microsoft Windows Common Controls-2 #.#"
ElseIf chkRef.GUID = "{B691E011-1797-432E-907A-4D8C69339129}" Then
sName = "ADODB"
sFile = "mmsado15.dll"
sDescr = "Microsoft ActiveX Data Objects 6.0 Library (part of MDAC)"
ElseIf chkRef.GUID = "{2A75196C-D9EB-4129-B803-931327F72D5C}" Then
sName = "ADODB"
sFile = "mmsado15.dll"
sDescr = "Microsoft ActiveX Data Objects 2.8 Library (part of MDAC)"
End If
' Check for MISSING REFERENCES
If chkRef.isbroken = True And (sFullPath <> "") Then
' REFERENCE NOT REGISTERED
' Potential to fix reference without user intervention per:
' http://www.vbaexpress.com/kb/getarticle.php?kb_id=267
' http://www.mrexcel.com/forum/showthread.php?t=442346
' Set to continue in case of error
On Error Resume Next
' Remove the MISSING reference
'vbProj.References.Remove chkRef ' *** LEFT THIS OUT ***
'Clear any errors so that error trapping for GUID additions can be evaluated
Err.Clear
' Add the reference - use zero for major & minor versions to pick latest.
vbProj.References.AddFromGuid GUID:=sGuid, Major:=0, Minor:=0
'If an error was encountered, inform the user
Select Case Err.Number
Case Is = 32813
'Reference already in use. No action necessary
Case Is = vbNullString
'Reference added without issue
Case Else
'An unknown error was encountered, so alert the user
MsgBox "A problem was encountered trying to add VbReference:" _
& vbNewLine & "GUID: " & sGuid _
& vbNewLine & "Name: " & sName _
& vbNewLine & "Description: " & sDescr _
& vbNewLine _
& vbNewLine & "Please check the references in your VBA project (VbReferences)!" _
, vbCritical + vbOKOnly, sProcSig & " Error!"
Call RefNotInstalled(sName, sFile, sDescr, sGuid)
End Select
ElseIf (sFullPath <> "") Then
'IS REGISTERED, do nothing
Else
' REFERENCE NOT INSTALLED
Call RefNotRegistered(sName, sFullPath, sDescr, sGuid)
End If
Next chkRef
The AddFromGuid wont work in this instance unless I code for all the possible GUID's for ADODB.
Same goes for AddFromFile as filename can be different too
(eg: msado15.dll or msado20.dll):
C:\Program Files\Common Files\System\ado\msado*.dll
Last edited: