Rob,
Thanks for your reply.
Meanwhile I've found the solution and my Word now exports the macro's when
it quits (AutoExit macro). I want to back up my macro's because they often
need debugging. Because of the large amount of macro's I have I do not want
to cut and paste them one by one.
The following code does the trick:
===================================================
Option Explicit
Public Sub AutoExit()
Dim t As Integer
Dim sServerPath As String
Dim sLocalPath As String
Dim sDateTime As String
'fill in the paths
sServerPath = ""
sLocalPath = ""
sDateTime = _
Right("00" & Year(Now()), 4) & _
Right("00" & Month(Now()), 2) & _
Right("00" & Day(Now()), 2) & _
Right("00" & Hour(Now()), 2) & _
Right("00" & Minute(Now()), 2) & _
Right("00" & Second(Now()), 2)
sServerPath = sServerPath & "\" & sDateTime
sLocalPath = sLocalPath & "\" & sDateTime
MkDir sServerPath
MkDir sLocalPath
With Word.Application.NormalTemplate.VBProject.VBComponents
For t = 1 To .Count
Select Case .Item(t).Name()
Case "ThisDocument"
'do nothing
Case Else
.Item(t).Export sServerPath & "\" & .Item(t).Name() & ".bas"
.Item(t).Export sLocalPath & "\" & .Item(t).Name() & ".bas"
End Select
Next t
End With
End Sub
===================================================
As you can see, there are two locations to which I export the macro's,,
because I use a laptop computer. A local one and one at a server. The path is
created from the year, mont, day, minutes and seconds. So you can go back to
a previous point if you should (accidentally, off course!) destroy one of
your macro's.
You can cut and paste the code into the AutoExit module.
Be sure to adjust the paths to your needs!
With kind regards,
W. Kooy
Netherlands