Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

eport all macro's inormal.dot to text files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
billmccoy - 05 Jul 2007 10:44 GMT
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?
Rob - 05 Jul 2007 14:00 GMT
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?
billmccoy - 05 Jul 2007 14:26 GMT
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

> 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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.