Copy a module from add-in to active doc

B

Bear

How do I copy a macro module from an add-in to the active document? (I'm
trying to insert an auto-open macro by copying it into the doc.)

I've used the Application.OrganizerCopy method to copy a toolbar that way,
but it fails if I try to copy a module. And if you open the organizer and
examine an add-in, you can't see the modules either.

You can only see the modules in the add-in when it's actually open.

Any help will be appreciated.

Bear
 
J

Jezebel

You'reon the right track: open the add-in, then you can copy the module.
Unless you're trying to do this programmatically, in which case you're
almost certainly on the wrong track: manipulating code through code is
tricky to say the least, and precluded entirely in many security set-ups.
 
B

Bear

Jezebel

That's exactly what I'm trying to do -- add code programatically. And after
much research, I came to the conclusion that the inability to copy code
programatically (using the organizer object) was, indeed, intended operation,
and a virus safeguard.

Maybe you can offer some suggestions for an alternative approach.

I'm setting up the target document to display variables stored in a table in
another document. When the target document opens, I need to load the table
into an array for reference during the session.

I could set up the document by attaching a template that already has an
auto-open macro, but then the original template wouldn't be available, etc. I
just prefer the idea of putting my code in an add-in, copying a toolbar that
accesses that code into the target document, etc.

Any ideas?

Bear
 
J

Jezebel

Trap the DocumentOpen event in the add-in.



Bear said:
Jezebel

That's exactly what I'm trying to do -- add code programatically. And
after
much research, I came to the conclusion that the inability to copy code
programatically (using the organizer object) was, indeed, intended
operation,
and a virus safeguard.

Maybe you can offer some suggestions for an alternative approach.

I'm setting up the target document to display variables stored in a table
in
another document. When the target document opens, I need to load the table
into an array for reference during the session.

I could set up the document by attaching a template that already has an
auto-open macro, but then the original template wouldn't be available,
etc. I
just prefer the idea of putting my code in an add-in, copying a toolbar
that
accesses that code into the target document, etc.

Any ideas?

Bear
 
B

Bear

Jezebel

Yes, thanks. That's going to work just fine. In fact, I'm going to abandon
copying the toolbar as well, and build it programatically into the document.

An additional benefit of trapping the events is that I can now have multiple
documents open, trap the DocumentChange event, and switch between different
tables.

Good deal.

Bear
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top