Access World Forums

Access World Forums (
-   Word (
-   -   Using vba to open existing template, close previous (

Spooky 07-06-2017 02:33 PM

Using vba to open existing template, close previous
Can anyone point me in the right direction to use a .dot file to open another .dot file and close the first one?
The background is Im trying to work around an existing problem.
In a network situation, I have many users of a single template file (eg and due to the multiple users, this restricts me from editing / changing the file as its locked by users. I also cant change the name of this file as users have a link to it.

My thought is to use a new to redirect users (with VBA) to a copy of the actual Template file.

An external config file could then be easily used by TemplateA to control which 'live' copy of the actual template file is accessed by users allowing me to update and maintain an alternate copy without network locking issues.

User opens (network locking problems)

User opens new -> activates or , Closes

Does that make sense?

How do I open, Open and then close returning focus to


Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add("C:\Users\Documents\ t")
objWord.Visible = True

I have no problems creating config and redirecting to specific copies, its just the opening / closing / focusing of word templates I am unfamiliar with
Or, if you have a better idea then Im all ears!


Ranman256 07-06-2017 02:47 PM

Re: Using vba to open existing template, close previous
Normally, you don't open a template (.dot) to edit...
You use it to open a blank document BASED on the template.
(This stops locking)

Documents.add template

Spooky 07-06-2017 03:53 PM

Re: Using vba to open existing template, close previous
The template itself is a method of creating many different documents, so its a complicated arrangement of user forms. Im frequently upgrading and adding more functionality, hence the need to edit or replace the single live running copy.

So, the end users do kind of open the document based on the template, but the template remains open and locked for about 10 minutes per session whilst that or others are using the userforms (or at least thats what I think is happening)

All times are GMT -8. The time now is 09:20 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World