Calling userforms from another file

M

Mat

Apologies if this is a basic question that’s been answered elsewhere, but I'm
having trouble framing questions that return results narrow enough to wade
thru.

I've written a userform that classifies documents in the word properties box
according to all sorts of business rules we have, and a complementary search
tool to go with it.
I've exported these forms and imported them into a BusinessObjects.DOT file.
I have placed this file in the startup templates folder and added them in
thru the Templates and Add-Ins.

My question is, how do I reference the userforms from a macro in the
normal.dot when the userforms reside in the BusinessObjects.DOT file? When
ever I try referencing them it falls over reporting that it requires an
object.

Cheers
 
J

Jezebel

First: why do this? One of the main reasons for using an add-in is that you
can put your code in it, to avoid putting any (shared) code in normal.dot.
Macros in your add-in are as easily accessible as those in normal.dot.
Putting your code there has several advantages: 1) it makes the add-in
self-contained; 2) it makes your code easier to maintain; 3) it makes you
code *much* easier to distribute because you don't have to screw around with
your users' normal.dot files; and 4) you don't leave meaningless code behind
in normal.dot (ie, that ceases to work if the add-in isn't loaded).

That said, you can do it by selecting the Normal project in VBA, then go to
Tools > References and add a reference to the Add-in project. That gives you
access to the public functions of the add-in code project. In the add-in,
write a sub that displays the form you want.
 
C

Charles Kenyon

If you put your template in the Word Startup folder (rather than the Office
Startup folder) it will be loaded and listed as checked under the Templates
and Add-Ins folder.

Put a macro in your template that loads an instance of your userform. Call
that macro from the other file. Application.Run
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide




--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
D

David L.

Is there anything special I need to do to access those macros? I have an
add-in template that has a module called "Library" and within it there are
numerous Subs and Functions... but I cannot seem to access them from other
modules. I get a runtime 424 error "Object Required."

- Thanks
 
D

Doug Robbins - Word MVP

Have you checked out the information in the Visual Basic Help file on the
Application.Run procedure?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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