Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #28  
Old 03-23-2022, 09:07 AM
Peterson Peterson is offline Content blocks stop working when changing file path Windows 10 Content blocks stop working when changing file path Office 2019
Competent Performer
 
Join Date: Jan 2017
Posts: 143
Peterson is on a distinguished road
Default

Right-clicking and selecting Open is how Microsoft designed Word to open template files so that you can work in them and not create a blank document based on them. There is no way to right-click on a template, select Open, and have it create a new blank document based on the template.

Your users are not using Word to create blank documents in the way Microsoft designed the program to work.

The primary method of creating a new file based on a template is via File > New. In the screen that appears, there is a Personal button. When users click Personal, Word displays all of the templates in the user's default template storage folder. The user should then click on the template with which they want to create a new document.

The other way to create a new file from a template is, as you noted, to double-click on a template that's already in a folder somewhere.

But, again, it is not possible to right-click on a template, select Open, and create a document based on that template.

To create a new file based on a template using VBA, use the following:
Code:
Sub CreateNewDocFromUserTemplate() ' 03/23/2022

    ' Create a variable for the filepath to your template:
    Dim strFilepath As String
    
    ' Use the Environ("UserProfile") function to get the first portion of the
    ' user's file path -- that is, C:\User\username -- and concatenate with the
    ' rest of the path to the template in your users' template folder:
    strFilepath = Environ("UserProfile") & _
    "\AppData\Roaming\Microsoft\Templates\Replace-This-With-Your-Template.dotm"
    
    ' Here's what the full string looks like:
    Debug.Print strFilepath
    
    ' Create new document based on template:
    Documents.Add (strFilepath)
    
End Sub
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mapped Content Controls in Building Blocks? Charles Kenyon Word 6 05-21-2021 05:40 PM
Stop hyperlink to a file from changing address - causes problems with pdf c.davidson Word 1 09-15-2020 11:11 PM
Content blocks stop working when changing file path New building blocks have stopped working (Word 2016) Genericname1111 Word 0 05-20-2020 04:17 PM
Content blocks stop working when changing file path Get image path from content control field - NO VBA possible thoerzer Word 5 10-10-2019 12:10 AM
Changing Absolute path to Relative in a Macro MrKim Excel Programming 13 01-26-2019 02:18 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft