Missing reference vs unchecked reference runtime

Kyle123

Well-known Member
Joined
Jan 24, 2012
Messages
2,771
I am in the unenviable position of coming up with a workbook that does a load of VBA for people with computers that I do not know the spec of. I know the below works when I remove the reference to MSXML, however am I likely to run into any issues should the relevant MSXML library be missing rather than me unselecting whilst testing? I don't know whether missing behaves differently to an unchecked reference.

Rich (BB code):
    Dim request As IWebRequest
    Dim parser As IDataParser

    Set request = New DataRequest

    request.Url = CONSTANTS.Url
    request.Authenticator = CONSTANTS.AUTH_STRING
    request.Timeout = 12
    request.CallType = Legacy
    
    If LateBind Then
        Set parser = New LegacyDataParser
    Else
        Set parser = New DataParser
    End If
    
    Set parser.WebRequest = request


IDataParser
Rich (BB code):
Public Property Set WebRequest(ByVal RHS As IWebRequest): End Property
Public Property Get WebRequest() As IWebRequest: End Property

Public Function GetData() As Variant: End Function

DataParser
Rich (BB code):
Option Explicit
Implements IDataParser

Private m_IWebRequest As IWebRequest

Private Function IDataParser_GetData() As Variant

    Dim doc As Object
    Set doc = New MSXML2.DOMDocument60

    doc.LoadXML m_IWebRequest.GetData
    IDataParser_GetData = ParseData(doc)
    
End Function
'...

LegacyDataParser
Rich (BB code):
Option Explicit
Implements IDataParser

Private m_IWebRequest As IWebRequest

Private Function IDataParser_GetData() As Variant

    Dim doc As Object
    Set doc = CreateObject("MSXML2.DOMDocument")

    doc.LoadXML m_IWebRequest.GetData
    IDataParser_GetData = ParseData(doc)
    
End Function

I've previously posted this at EF here, but had no response: https://www.excelforum.com/excel-pr...reference-vs-unchecked-reference-runtime.html
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
As long as you haven't selected the reference, there shouldn't be a problem. Is LateBind being determined at run-time?
 
Upvote 0
Yes, and by default it will use early binding - there's a reference set to "Microsoft XML, v6.0", however I've included an option for whoever is supporting the user (read me ;)) to change this should there be problems. I don't really want to maintain 2 workbooks and code bases and coding against an older library is so slow it's not much better than late binding.
 
Last edited:
Upvote 0
Is there a reason for not using conditional compilation?
 
Upvote 0
Yes, I couldn't figure out how to add conditional compilation arguments to a worksheet. I'd like to be able to talk a user through changing a setting on a worksheet that allows them to change the value of LateBind without talking them through adding arguments in the VBE.

Do you have a nifty way of doing it?
 
Last edited:
Upvote 0
Nope. :) You said you were supporting so I assumed you were making the changes too...
 
Upvote 0
Haha nope, by supporting, I will do it on the phone or ideally pass it off to the IT service desk :)

What do you reckon then? Will this work with missing references? If not any other ideas how I could do it?
 
Upvote 0
As long as the code is separated enough that the version without the reference will never cause the bits that need it to compile, you should be fine. There certainly shouldn't be any of the issues with missing references and unrelated code.
 
Upvote 0
Brill, ta muchly. It works when I unset the reference so that's good enough.

PS thanks for the rep on the other thread :D
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top