Go Back   Access World Forums > Apps and Windows > Word

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-06-2017, 02:33 PM   #1
Spooky
Newly Registered User
 
Join Date: Jun 2012
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Spooky is on a distinguished road
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 TemplateA.dot) 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 TemplateA.dot 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.

Current:
User opens TemplateA.dot (network locking problems)

Proposed:
User opens new TemplateA.dot -> activates Copy1.dot or Copy2.dot , Closes TemplateA.dot

Does that make sense?

Question:
How do I open TemplateA.dot, Open Copy.dot and then close TemplateA.dot returning focus to Copy.dot.

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

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!

TIA

Spooky is offline   Reply With Quote
Old 07-06-2017, 02:47 PM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 2,452
Thanks: 0
Thanked 529 Times in 515 Posts
Ranman256 will become famous soon enough
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
Ranman256 is offline   Reply With Quote
Old 07-06-2017, 03:53 PM   #3
Spooky
Newly Registered User
 
Join Date: Jun 2012
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Spooky is on a distinguished road
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)

Spooky is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easiest way to import data into existing Template Dave 14867 General 1 02-21-2017 01:08 AM
How to attach a PDF-Report to existing Outlook Template jmangual Modules & VBA 3 05-22-2015 02:15 PM
Open form and close existing form jschneider998 Modules & VBA 1 12-26-2002 11:59 AM
When open form close previous Haytham Modules & VBA 6 09-28-2001 05:52 AM
Close Access97 Open Sessions and Then Close Database- new twist llyal Modules & VBA 2 04-11-2000 04:07 AM




All times are GMT -8. The time now is 05:29 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


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