Hello,

Is it possible to run a peice of code without checking to see if variables/objects/etc.. exist?

I want Excel to remove missing references and add the appropriote references based on what version of VBA is being used:

Private Sub Workbook_Open()
    
    'Add/Remove appropriote References
    #If VBA7 Then
        If Not AddReference("{6857A7F4-4CDE-43F2-A7B1-CB18BA8AA35F}") _
            Then Exit Sub
        If Not AddReference("{0D5D17DF-B511-4BE5-9CD0-10DE1385229D}") _
            Then Exit Sub
        If Not AddReference("{3BA4C5BF-F24A-4BE4-8BAB-8BD78C2FABDE}") _
            Then Exit Sub
        If Not AddReference("{88EC0C50-0C86-4679-B27D-63B2FCF1C6F4}") _
            Then Exit Sub
        If Not AddReference("{00062FFF-0000-0000-C000-000000000046}") _
            Then Exit Sub
    #Else
        If Not AddReference("{7FAE9440-C040-11CD-B010-0000C06E6B8A}") _
            Then Exit Sub
        If Not AddReference("{00062FFF-0000-0000-C000-000000000046}") _
            Then Exit Sub
    #End If
End Sub
I want the above code to run before it does all the compiling checks.

The excel macro will be used on Windows 7 and Windows XP machines. For some reason, if a reference is missing, when I open the workbook, all it does is give me an error and then highlights a peice of common code (like Mid, or Trim).