Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to save Macros

:-) I had forgotten this one.

Bob


"davegb" wrote in message
oups.com...
Bob, thanks a lot. Works great now!

Bob Phillips wrote:
Sorry Dave, I was lazy for you. Try this

Sub ExportAllVBA()
Const vbext_ct_StdModule As Long = 1
Const vbext_ct_ClassModule As Long = 2
Const vbext_ct_MSForm As Long = 3
Const vbext_ct_Document As Long = 100
Dim VBComp As Object
Dim Sfx As String

For Each VBComp In ActiveWorkbook.VBProject.VBComponents
Select Case VBComp.Type
Case vbext_ct_ClassModule, vbext_ct_Document
Sfx = ".cls"
Case vbext_ct_MSForm
Sfx = ".frm"
Case vbext_ct_StdModule
Sfx = ".bas"
Case Else
Sfx = ""
End Select
If Sfx < "" Then
VBComp.Export _
Filename:=ActiveWorkbook.Path & "\" & VBComp.Name & Sfx
End If
Next VBComp
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"davegb" wrote in message
oups.com...
Thanks, Bob
I set VBComp = 0, but it still doesn't recognize the user defined
variable. Any other ideas?

Bob Phillips wrote:
Change that variable to 0 (zero)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"davegb" wrote in message
ups.com...
Modified the macro and declared VBComp as Object. Now I'm getting
"Variable not defined" on vbext_ct_ClassModule. I don't recognize

this
kind of variable. How do I define it?
I don't know how to reference the extensibility library.
Thanks.

Bob Phillips wrote:
You need to set a reference to the Microsoft Visual Basic for
Applications
Extensibility library, or just use

Dim VBComp As Object

--

HTH

RP
(remove nothere from the email address if mailing direct)


"davegb" wrote in message
oups.com...
Thanks for all your replies!
Steve,
When I try to run your macro, I'm getting a "User defined type

not
defined" error on the

Dim VBComp As VBIDE.VBComponent

line. I tracked it down on Chip's page, and found that it

needs
access
to a file in Winhelp which I can't access. Is there a

workaround
for
that?
Thanks!

STEVE BELL wrote:
This is from Chip Pearson's site -

http://www.cpearson.com/excel/vbe.htm



Exporting All Modules In A Project
The procedure below will list export all of the modules in a
workbook to
text files. It will save the files in the same folder as the
workbook.
This
can be useful for saving a backup copy of your VBA, or for
transferring
VBA
code from one project to another.

Sub ExportAllVBA()
Dim VBComp As VBIDE.VBComponent
Dim Sfx As String

For Each VBComp In ActiveWorkbook.VBProject.VBComponents
Select Case VBComp.Type
Case vbext_ct_ClassModule, vbext_ct_Document
Sfx = ".cls"
Case vbext_ct_MSForm
Sfx = ".frm"
Case vbext_ct_StdModule
Sfx = ".bas"
Case Else
Sfx = ""
End Select
If Sfx < "" Then
VBComp.Export _
Filename:=ActiveWorkbook.Path & "\" & VBComp.Name

&
Sfx
End If
Next VBComp
End Sub



--
steveB

Remove "AYN" from email to respond
"Jim Thomlinson" wrote in

message
...
You have lost me a bit here. When you save a spreadsheet

all
of
the
macros
are saved with it. If you have any modules, classes or

forms
that
are
particularily useful and you would want to use them in

other
projects
you
can
export them, to be imported into the other porjects. With

addin's
you
just
have to remember to save them when you make changes and

before
you
exit
excel
(or remove the addin). If this does not cover it let us

know... Or
maybe I
am
just missing something...
--
HTH...

Jim Thomlinson


"davegb" wrote:

I googled here, but no joy. So, is it possible to create

a
macro
to
save all my macros? I've accumulated quite a set by now,

with
a
lot
of
help here, and I've saved the modules. But it's getting

tedious
to
save
them all. Has anyone done this?








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to save macros Raewyn Excel Discussion (Misc queries) 3 December 29th 05 04:22 PM
Macros inside macros, and pasting into macro code. pagelocator[_2_] Excel Programming 1 November 24th 04 09:11 AM
save as using macros legepe[_8_] Excel Programming 1 October 23rd 04 12:32 AM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM


All times are GMT +1. The time now is 12:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"