Thread: [Solved] Generating a Letter
View Single Post
 
Old 09-23-2015, 09:14 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

For a document template, the userform and the macro that drives it should go in the document template and not the normal template. However it can work for any document in the normal template.

The simple userform example from the link contains all the code relating to the userform, however, as mentioned on the linked page, you need to to call the form from the document/template. This is done from a simple macro in a project module. http://www.gmayor.com/installing_macro.htm


Option Explicit
Sub ShowMyForm()
UserForm1.Show
Unload UserForm1
End Sub


If you want the form to display automatically when you create new documents from the template, create an autonew macro
in the template to call the above macro e.g.
Sub AutoNew()
ShowMyForm
End Sub

This however relates to document templates only as you don't want the form popping up every time you create a document from the normal template
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote