PDA

View Full Version : update or overwrite template in startup



saban
10-11-2006, 05:59 AM
How can I update or overwrite template in startup folder using VBA

startdir = Application.Options.DefaultFilePath(wdStartupPath)

It is not a problem to copy template with a click on a button but the problem is if I want to overwrite existing template in STARTUP folder beacuse word is using it.

Any ideas how can I avoid this usage of certain template in startup? Is it possible to somehow write to the code that it should not use startup folder at time of overwriting

Thnx

And how can I use path with variable: i.e.
"\\DG7BLUXSNCF02\Users\name\Application (file://\\DG7BLUXSNCF02\Users\name\Application) Data\Microsoft\Word\STARTUP\Stetjebold.dot" _
).Installed = False
name = application.username
Any ideas

saban
10-11-2006, 07:07 AM
Private Sub CommandButton1_Click()
On Error GoTo Fail
Dim startdir As String
startdir = Application.Options.DefaultFilePath(wdStartupPath)
If startdir = "" Then GoTo Fail
If Dir(startdir & "\" & "Stetjebold.dot") = "" Then
ActiveDocument.SaveAs FileName:=startdir & "\" & "Stetjebold.dot"
MsgBox "Datoteka je bila skopirana v tvoj Startup." & vbCrLf & "Ponovno za?eni word da bodo spremembe vidne Hvala"
Else
If Dir(startdir & "\" & "Stetjebold.dot") = Dir(startdir & "\" & "Stetjebold.dot") Then
KillFile = Dir(startdir & "\" & "Stetjebold.dot")
Dim ime As String
ime = Application.UserName
Dim scenca
AddIns( _
startdir & "\" & "Stetjebold.dot").Installed = False

End If
ActiveDocument.SaveAs FileName:=startdir & "\" & "Stetjebold.dot"
MsgBox "Datoteka je bila posodobljena." & vbCrLf & "Ponovno za?eni word da bodo spremembe vidne Hvala"
AddIns( _
startdir & "\" & "Stetjebold.dot").Installed = True
End If
End
Fail:
MsgBox "Ni mo?o shraniti v startup folder " & vbCrLf & "Poglej ali ima? nastavljeno pot za startup" & vbCrLf & "Tools/Options/filelocations"
End Sub


just disable add-ins and that is it

fumei
10-11-2006, 07:11 AM
Good for you. Thank you for following up and posting that you figured it out.

Did you also get the answer to the user name variable?

saban
10-11-2006, 08:35 AM
no that one I didnt find(user name variable)

Stay cool and Thnx for everything