eport all macro's inormal.dot to text files

B

billmccoy

I have lots of macro's that I want to export to text files, but I don't want
to export them one by one (time consuming!). I was trying to do this form VB
2005 Express, but I can't find how to get access to the macro's. Is there an
easy way to do this?
 
R

Rob

Can you clarify "export" and why? You could just export the module if you
didn't NEED it to be in a text file. And what about Ctrl+A, Ctrl+C and paste
it into a text file?
 
B

billmccoy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top