class module

Discussion in 'AutoCAD' started by cesi2d, Sep 8, 2004.

  1. cesi2d

    cesi2d Guest

    Hi,

    For our developpement , I want to create an utility VBA project , inside
    this project creating some class modules.

    From others projects , how can I dynamicaly create objects referencing one
    one the class in the utility project ?
    (the NEW instruction can't access to a module outside the current project)

    Thanks

    --
    Cesi2d
    Luc Vallot
    Chemin du Bassard
    38121 Chonas l ' amballan
    France


    Tel: 04 74 58 95 68
     
    cesi2d, Sep 8, 2004
    #1
  2. Create a function in a standard module of the class' project that creates a
    new instance of the object and returns the object. Search this ng for recent
    posts on reusing code for more details if you need them.

    --
    R. Robert Bell


    Hi,

    For our developpement , I want to create an utility VBA project , inside
    this project creating some class modules.

    From others projects , how can I dynamicaly create objects referencing one
    one the class in the utility project ?
    (the NEW instruction can't access to a module outside the current project)

    Thanks

    --
    Cesi2d
    Luc Vallot
    Chemin du Bassard
    38121 Chonas l ' amballan
    France


    Tel: 04 74 58 95 68
     
    R. Robert Bell, Sep 8, 2004
    #2
  3. cesi2d

    Tim Arheit Guest

    You can sort of.

    In the Utility project:
    -Set the Instancing property of the classes to Public NotCreatable.
    (Unfortunately you don't have the option of simply Public, so it
    won't work directly with NEW in another project, but....)
    - Add a module with the function NewMyClass that returns a new copy
    of the class.
    - You will want to change the project name to something other than
    the default name of ACADProject. ie. change it to Utility or somthing
    similar.

    In the other projects:
    - Make sure References (under tools References) has the utility
    project checked.
    - Now you can simply do:
    Set ob = NewMyClass
    or
    Set ob = Utility.NewMyClass


    -Tim
     
    Tim Arheit, Sep 8, 2004
    #3
  4. cesi2d

    cesi2d Guest

    very nice

    thanks to Tim Arheit and Robert Bell

    Luc
     
    cesi2d, Sep 9, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.