Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Export VBA Code to Text File

I am new in VBA and need to find a way to export all modules to text file.
Any suggestion that works? I've been trying some samples... they might work
but theres no clear instruction on how to setup it in step by step.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Export VBA Code to Text File

I usually just copy mine to either MS Word or Notepad. Never bothered with
doing it by code.



"mark ivanowski" wrote in message
...
I am new in VBA and need to find a way to export all modules to text file.
Any suggestion that works? I've been trying some samples... they might
work
but theres no clear instruction on how to setup it in step by step.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Export VBA Code to Text File

A simple piece of code will do it.

Sub ExportMod()
Dim ModName As String
Dim FName As Variant
ModName = "Module1"
FName = Application.GetSaveAsFilename( _
filefilter:="Module Files (*.bas),*.bas", _
Title:="Export")
If FName = False Then
' getfilename cancelled
Exit Sub
Else
On Error GoTo NoDelete:
Kill FName
End If
ThisWorkbook.VBProject.VBComponents(ModName).Expor t FName
Exit Sub
NoDelete:
MsgBox "The file '" & Filename & "' cannot be deleted." & vbCrLf &
_
"Error: " & CStr(Err.Number) & " " & Err.Description
End Sub

Change

ModName = "Module1"

to the name of the module you want to export. The code will prompt you
for the SaveAs file name. If you cancel this dialog, the code
terminates. If the SaveAs filename exists, the code deletes it. If
this delete operation is not successful, the module is not exported
and the code throws up a MsgBox indicating the error.

See http://www.cpearson.com/Excel/VBE.aspx for lots more info about
working with the VBA editor via code.


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Sat, 7 Nov 2009 10:41:02 -0800, mark ivanowski
wrote:

I am new in VBA and need to find a way to export all modules to text file.
Any suggestion that works? I've been trying some samples... they might work
but theres no clear instruction on how to setup it in step by step.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Export VBA Code to Text File

hi
see this site.
http://cpearson.com/excel/vbe.aspx

you are looking for the "export vb component to a text file" part.

Regards
FSt1

"mark ivanowski" wrote:

I am new in VBA and need to find a way to export all modules to text file.
Any suggestion that works? I've been trying some samples... they might work
but theres no clear instruction on how to setup it in step by step.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 461
Default Export VBA Code to Text File

Rob Bovey's Code Cleaner utility (free from http://appspro.com) exports,
deletes, then imports code modules in order to clean up those nasty VB
projects.

One of its options is to simply export all modules. When exported, the
modules are essentially test files.

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



mark ivanowski wrote:
I am new in VBA and need to find a way to export all modules to text file.
Any suggestion that works? I've been trying some samples... they might work
but theres no clear instruction on how to setup it in step by step.

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
Export worksheet in New File by VBA code [email protected] Excel Programming 3 July 5th 07 03:53 PM
Export excel file to semicolon delimited text file capitan Excel Discussion (Misc queries) 5 April 7th 05 03:06 AM
Import VBA Code in Excel-File ? (Export VBA Code to file) Matthias Pospiech Excel Programming 2 March 22nd 05 04:56 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Request Vba code Export gif file Luigi[_2_] Excel Programming 3 February 17th 04 12:52 PM


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