View Single Post
 
Old 08-14-2020, 08:10 PM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

If the templates were in the Project1 folder of the Workgroup Templates folder I would use that as a base path.


I use a function to get that path:


Code:
Private Function WorkGroupPath() As String
'   Written by Charles Kenyon
'   February 28, 2003
'
'   Used by templates menus to set location of templates.
'   Returns workgroup tempates path with "\" at the end.
'
'   This is needed because if the folder is a network drive rather
'   than a folder, it will have the "\" already. If it is a folder,
'   it will not have the backslash. This function gives a string
'   with the backslash in either case.
'
    WorkGroupPath = Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
    If Right(WorkGroupPath, 1) <> "\" Then
        WorkGroupPath = WorkGroupPath & "\"
    End If
End Function
In my userform, to create a new document from the template Template2.dotx in the Workgroup Templates subfolder Project1 I would use the following statements:


Code:
Dim oDocument2 as Document
Dim strTemplate2 as String


Let strTemplate2 = WorkGroupPath & Project1 & "\Template2.dotx"

Set oDocument2 = Documents.Add(Template:=strTemplate2)

You could then fill in bookmarks in oDocument2 and save it.


Note, I have not tried this code directly but run something similar on a regular basis.
Reply With Quote