PDA

View Full Version : [SOLVED:] How do I delete a global template file?



HelenT
06-29-2016, 03:06 AM
Hello,

I want to delete a global template file from the start-up folder and replace it with another. How do I go about deleting the global template file via VBA?

I have looked and looked in Word help and on Google but cannot find the answer!!

Many thanks, Helen.

gmayor
06-29-2016, 04:52 AM
The following will delete the global template filename.dotm using VBA

Dim strPath As String
Const strName As String = "filename.dotm"
strPath = Application.Options.DefaultFilePath(wdStartupPath) & Chr(92)
AddIns(strPath & strName).Installed = False
Kill strPath & strName

HelenT
07-06-2016, 02:12 AM
Thanks, Graham, that's just the job! :bow:

Paul_Hossler
07-06-2016, 06:39 AM
Instead of Chr(92) or "\", you could use Application.PathSeparator

IIRC there are localization issues that it handles better