Macro to do a File, New to a different template folder

I

Ilene

I need a macro that does a File | New, but not to the
UserTemplate or WordGroup Template folder. My Workgroup
template folder is at i:\Wordtemplates. I want it to go
to i:\Wordtemplates\Other and just have it list the
contents so the user can give a double-click on the
template she needs. I don't want to open a particular
template - i want to see the list.

Don't know why i can't get this one together. Thanks!
ilene
 
D

Doug Robbins - Word MVP

Use:

'Declare a variable as a FileDialog object.
Dim fd As FileDialog, SelectedTemplate As String

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Use a With...End With block to reference the FileDialog object.
With fd
'Set the caption for the File Picker dialog
.Title = "File New"
'Restrict the user to selecting one template
.AllowMultiSelect = False
'Set the path
.InitialFileName = "i:\Wordtemplates\Other\"
'Use the Show method to display the File Picker dialog box and
return the user's action.
'The user pressed the action button.
If .Show = -1 Then
'vrtSelectedItem is a String that contains the path of each
selected item.
SelectedTemplate = .SelectedItems(1)
'The user pressed Cancel.
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
'Display the path\filename of the selected template
MsgBox "You selected " & SelectedTemplate
'Create a new document from the selected template
Documents.Add SelectedTemplate

As this only works with recent versions of Word, if it doesn't work for you,
modify the code in the article "Insert into a document the names of all
files in a selected folder" at:

http://word.mvps.org/FAQs/MacrosVBA/InsertFileNames.htm

to populate a listbox on a userform with the names of the templates.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
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