Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What is the quickest way in Excel 2007 to export all modules?

I would like to find a way to reduce the amount of time it takes to export
all the VBA source code from a spreadsheet to a text file in Excel 2007.
Currently, I click on each module in turn, then go to File, Export, etc.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default What is the quickest way in Excel 2007 to export all modules?

Get hold of a copy of Rob Bovey's indispensable Code Cleaner utility,
http://www.appspro.com/Utilities/CodeCleaner.htm

Although he calls it CodeCleaner, as it works by exporting all modules and
re-importing them, Rob provide an option to just export.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Ullrich Fischer" <Ullrich wrote in
message ...
I would like to find a way to reduce the amount of time it takes to export
all the VBA source code from a spreadsheet to a text file in Excel 2007.
Currently, I click on each module in turn, then go to File, Export, etc.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default What is the quickest way in Excel 2007 to export all modules?

This works in XL 2003. It needs a reference to the Extensibility library.
You could get rid of all the GetDirectory code if you hard-code the folder
to save the files to.

Option Explicit
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As
Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As
Long

Function GetDirectory(Optional strTitle As String = "") As String

Dim bInfo As BROWSEINFO
Dim Path As String
Dim r As Long
Dim x As Long
Dim pos As Integer

'Root folder (&H0 for Desktop, &H11 for My Computer)
bInfo.pidlRoot = &H0

'Title in the dialog
If Len(strTitle) = 0 Then
bInfo.lpszTitle = "Select a folder."
Else
bInfo.lpszTitle = strTitle
End If

'Type of directory to return
bInfo.ulFlags = &H1

'Display the dialog
x = SHBrowseForFolder(bInfo)

'Parse the result
Path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal Path)
If r Then
pos = InStr(Path, Chr$(0))
GetDirectory = Left(Path, pos - 1)
Else
GetDirectory = ""
End If

End Function

Sub ExportAllVBA()

Dim VBProj As VBProject
Dim VBProjToExport As VBProject
Dim VBComp As VBIDE.VBComponent
Dim Sfx As String
Dim strFolder As String
Dim strFile As String

For Each VBProj In Application.VBE.VBProjects
On Error Resume Next
Select Case MsgBox("Export all modules of this project?", _
vbYesNoCancel + vbDefaultButton2, _
VBProj.Filename)
Case vbYes
Set VBProjToExport = VBProj
Exit For
Case vbNo
Case vbCancel
Exit Sub
End Select
Next

If VBProjToExport Is Nothing Then
Exit Sub
End If

'so overwrite old files without warning
'--------------------------------------
Application.DisplayAlerts = False

strFolder = GetDirectory("pick a folder to export the modules") & "\"

For Each VBComp In VBProjToExport.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
Application.StatusBar = " Exporting to " & _
strFolder & _
VBComp.Name & Sfx
VBComp.Export _
Filename:=strFolder & VBComp.Name & Sfx
End If
Next VBComp

With Application
.StatusBar = False
.ScreenUpdating = True
End With

End Sub


RBS



"Ullrich Fischer" <Ullrich wrote in
message ...
I would like to find a way to reduce the amount of time it takes to export
all the VBA source code from a spreadsheet to a text file in Excel 2007.
Currently, I click on each module in turn, then go to File, Export, etc.


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
MS WORKS DOCUMENTS TO MS OFFICE 2007; QUICKEST TO TRANSFER ShaneDevenshire Excel Discussion (Misc queries) 1 November 9th 08 01:29 PM
MS WORKS DOCUMENTS TO MS OFFICE 2007; QUICKEST TO TRANSFER TNT66 Excel Discussion (Misc queries) 0 November 8th 08 10:22 PM
Export modules from protected projects Frederick Chow Excel Programming 1 April 16th 06 10:10 PM
Export modules from protected projects Frederick Chow Excel Programming 0 March 21st 06 05:02 PM
auto-export VBA modules Christopher Merrill Excel Programming 1 September 20th 05 06:53 PM


All times are GMT +1. The time now is 11:29 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"