PDA

View Full Version : open template double click



saban
10-12-2006, 12:54 AM
Is it possible somehow to open template with double click

Any ideas
Thnx

geekgirlau
10-12-2006, 11:49 PM
I'm not sure exactly what you mean ...

saban
10-13-2006, 12:37 AM
Because if you open a template with double click word makes a temporary file of template it does not open template itself

I have made a template with command button on it to copy itself to startup folder (WdStartupPath) but it must be open properly not with double click and then users can deploy template with click on a button

fumei
10-13-2006, 07:29 AM
Because if you open a template with double click word makes a temporary file of template it does not open template itselfDouble clicking a template (.DOT) files does NOT open the file. It does NOT make a temporary file. Double clicking does what a template file is designed to do - create a cloned copy of the template file.

I have made a template with command button on it to copy itself to startup folder (WdStartupPath) but it must be open properly not with double click and then users can deploy template with click on a buttonThat is a very strange thing to do.

WHY would you have a template commandbutton to copy it to Startup? Why is it not just in Startup? WHY are the users making a decision to "deploy" the template as a global - which is what putting a template file in Startup is.

saban
10-14-2006, 11:19 AM
Because i dont have rights to copy template into their folder only each user and main administrators have user to this startup folders get it?

So only each user or administrator can copy templates to startup

fumei
10-14-2006, 10:19 PM
So.....you are trying to bypass your permissions. Hmmm.

Normally, you can do straight file copy commands with:FileCopy Source, Destination

HOWEVER, a document cloned from a template will NOT allow this. You will get a Permission denied error. This is because unless the .DOT is explicitly opened in Word, it is locked. You CAN open the .DOT then do a SaveAs to wdStartupPath.

The best way is to use FileSystemObject. You will need a Reference to the Microsoft Scripting Runtime library in the .DOT file. But you do it like this:Private Sub CommandButton1_Click()
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Set fso = CreateObject("Scripting.FileSystemObject")
Set fil = fso.GetFile("C:\temp\testcopy.dot")
fil.Copy "c:\test\testcopy.dot"
Set fil = Nothing
Set fso = Nothing
End SubThis will make a copy of c:\temp\testcopy.dot and put it in c:\test as testcopy.dot.

This code WILL work in a document cloned from the template testcopy.dot.

However, you don't even need a commandbutton to do this. If you just want to go ahead and make the copy, then simply use the Document_New event of the template.Private Sub Document_New()
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Set fso = CreateObject("scripting.FileSystemObject")
Set fil = fso.GetFile("C:\temp\testcopy.dot")
fil.Copy "c:\test\testcopy.dot"
Set fil = Nothing
Set fso = Nothing
End SubThe template is used to make a new document...it will automatically make a copy. Of course you will need to use the correct paths and filenames.

saban
10-16-2006, 12:18 AM
Thnx man I really apreciate this
Stay cool