User Form to select Template For New Docs

M

malycom

Hi

I'm always amazed byt the help I have had on these forums so I hope I can
get the same help again.

I need help creating a user form.
This user form will contain a list field which contains the letter templates
we have set up.

Assume I have two templates set up called new-clients.dot, resignations.dot
and conference.dot and they are located in G\Templates, how would I code the
userform to show these three templates. I would like the list text to show
whatever wording I choose and not the path.

I would want the user to select one of the listed but not open a document
until they have pressed a command button.

When the command button is pressed, I would like a new .doc document to open
based on the .dot template they selected and then close the user form.

You help would be greatly appreciated.

Cheers
 
G

Graham Mayor

Presumably this is Word 2003, or earlier, given your mention of dot
templates? Wouldn't it be simpler to create a new menu item in Word to
contain macros to open documents based on the three templates, rather than a
userform which you are going to have to call?

However with a userform at its simplest containing a listbox and a command
button the following code associated with the form would display the three
templates and create a new document from the selected one

Private Sub UserForm_Initialize()
With ListBox1
.ColumnCount = 1
.AddItem "New Clients"
.AddItem "Resignations"
.AddItem "Conference"
End With
End Sub

Private Sub CommandButton1_Click()
Select Case ListBox1.Value
Case Is = "New Clients"
Documents.Add "G:\Templates\New-Clients.dot"
Case Is = "Resignations"
Documents.Add "G:\Templates\Resignations.dot"
Case Is = "Conference"
Documents.Add "G:\Templates\Conference.dot"
Case Else
End Select
Unload Me
End Sub


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

malycom

Thank you Graham
I understand what you mean about the Macro but your solution has been
absolutely perfect for my needs today.

Once again, another problem solved.

Cheers
 

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