Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing trouble in excel
Message
 
À
Tous
Information générale
Forum:
Microsoft Office
Catégorie:
Excel
Titre:
Referencing trouble in excel
Versions des environnements
Microsoft Office:
Office 2010
Divers
Thread ID:
01550398
Message ID:
01550398
Vues:
60
Please consider the class below. The "instancing" property is set to "2-PublicNotCreatable"

When I instantiate from the Immediate Window it works.

Yet when I instatiate it in a module of a project that references the library in which the class is located, the compiler gives me a "invalid use of new" error.
Option Explicit
Dim oWB As Workbook
'-----------------------------
Private Sub Class_Initialize()
    Set oWB = Workbooks.Open("P0040" & "Config.XLSX")
    Dim oRng As Range
    Set oRng = oWB.Sheets(1).Range("A1").CurrentRegion
    Dim oName As Name
    For Each oName In Names
        oName.Delete
    Next
    oRng.CreateNames False, True, False, False
End Sub
'--------------------------------------------
Public Function uValue(cConfigName As String)
    uValue = oWB.Sheets(1).Range(cConfigName)
End Function
'--------------------------------------
Public Sub setValue(cConfigName, uValue)
    oWB.Sheets(1).Range(cConfigName) = uValue
End Sub
'----------------------------
Private Sub Class_Terminate()
    oWB.Close False
    Set oWB = Nothing
End Sub

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform