Using a Normal module to load and show a userform in theactivedocument

P

Patrickw

What is the syntax to load and show a userform stored in a document
template (other than the normal template) from the normal template?

I have tried

Load ActiveDocument.myUserForm
ActiveDocument.myUserForm.Show

as well as

Load ThisDocument.myUserForm
ActiveDocument.myUserForm.Show
 
D

Doug Robbins - Word MVP

If the userform is in the template of the active document, why not just use
code in that template to load it? That would be the normal thing to do.

--
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, originally posted via msnews.microsoft.com
 
P

Patrickw

Thanks, but there is a reason I cannot use the direct method. I tried
running the module from the Document Open command. Problem is, I am
using a third party program called Time Matters, which performs a mail
merge to the document first. Trying to open the form when the
document first opens interferes with the mailmerge. There is a
command line in time matters that lets me run a macro, but the macro
must be stored in the normal template. I am bloating the normal
template with all the custom userforms I want to run. What I really
want to do is limit use of Normal to short modules necessary to call
the userform stored in the mailmerge document template I am running at
the time. That way, the userforms can be stored with the document
template while the code to call the userform resides in the Normal
template. portable
 
G

Graham Mayor

If the macro to call the userform is stored in the document template (here
doc2.dot) then you could call it from normal.dot eg

Dim oDoc As Document
Set oDoc = ActiveDocument
If InStr(1, LCase(oDoc.AttachedTemplate), "doc2.dot") Then
Application.Run MacroName:="ShowForm"
Else
MsgBox "Macro not available", vbCritical, "No Macro"
End If

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Patrickw

Made it work, only to discover that Time Matters (a client management
database) automatically saves the document template as a document in
the client's folder after the data mail merge takes place, but before
the macro is executed. Thus, there is no macro remaining in the
document left to call after the merge.
 
G

Graham Mayor

Then store it in the normal template or an add-in template.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Patrickw

Thanks for all your help on this. Great ideas that at least helped me
get a better understanding of how my programs are interacting.
Hopefully, this will make future macro programming a little less
frustrating.
 

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