# Export all VBA code to text file



## grahamj42

I have 2 versions of the same spreadsheet from a 3rd party.

The visual changes are easy to see but I need to check if there are code changes.

The logicical process seems to be to export all code  from each app to a text file and the run the 2 text files through a file compare program.

Can this be done, please?

Graham


----------



## Richard Schollar

Hi Graham

Can't help you with a program to use for the comparison, but certainly VBA module contents can be exported into a text file (right-click on the module in the Project window of the VBE and select Export.  You export it as a .bas file but these are simply text files that can be opened in a text editor eg Notepad.


----------



## grahamj42

Thanks Richard

I forgot to state in my post that I'm using Excel 2007 + Win XP.

You solution works fine for Modules but when I try it on the Objects (Sheet code) it exports .cls which don't appear to be readable.

File comparison isn't a problem - I use an ancient version of CompareIt - I'd be lost without it.

Graham


----------



## Ruddles

You're welcome to give this a try: http://www.rula.pwp.blueyonder.co.uk/testarea/export_external_module_code_v2.xlsm.

Click the _Export_ button and pick the file(s) you want to export. The modules will be exported to a sub-folder called *CodeStore*.


----------



## shg

You can also use CodeCleaner to do the export.


----------



## Ruddles

Or even this: http://www.rula.pwp.blueyonder.co.uk/testarea/browse_vba_code_v2.xlsm.

Click _New File _to open a workbook and then _View _to view the code. Return to the module listing by clicking _List Modules_.

The _Import _button doesn't work yet!


----------



## grahamj42

Hi Ruddles

I followed the link but there wasn't a .xlsm - have I missed something?

Graham


----------



## Ruddles

I just tested both the links I posted and they worked okay. You should get a prompt "Do you want to open or save this file?" and you save it to disk and then open it from there.

Is it blocked by a corporate firewall perhaps?

If you're still experiencing problems, PM me your address and I'll email them to you.


----------



## grahamj42

shg4421 said:


> You can also use CodeCleaner to do the export.


Thanks, I will have a look.

Graham


----------



## Moonglum

I created a .NET component to read XLSM files. 
The webpage is here Extract XLSM and XLAM VBA Source Code

I was able to extract all the VBA code from your browse_vba_code_v2.xlsm file using it.


----------



## grahamj42

I have 2 versions of the same spreadsheet from a 3rd party.

The visual changes are easy to see but I need to check if there are code changes.

The logicical process seems to be to export all code  from each app to a text file and the run the 2 text files through a file compare program.

Can this be done, please?

Graham


----------



## riaanjbt

Site cannot be reached


----------



## Ruddles

Which one?  *www.rula.pwp.blueyonder.co.uk* or


----------



## Spyros13

There was a virus malware tojan ransome ware type thing & page horrible that came out of one these links.

Just letting admins know.


----------



## Ruddles

For the record, and to save anyone trying for themselves, it wasn't the Blueyonder site.  That was mine and has been down for many years.


----------



## Fluff

For the record, the dodgy link has now been removed.


----------



## Ruddles

Fluff said:


> For the record, the dodgy link has now been removed.



Thank you.  I didn't know you could do that.  You may as well remove the other one, since it goes nowhere.

I know this thread is over a decade old, but I wonder if there's any value in posting my code for exporting all the VBA code from  Excel/Access/Word files?

Or I could start a new thread?


----------



## Spyros13

Ruddles said:


> Thank you.  I didn't know you could do that.  You may as well remove the other one, since it goes nowhere.
> 
> I know this thread is over a decade old, but I wonder if there's any value in posting my code for exporting all the VBA code from  Excel/Access/Word files?
> 
> Or I could start a new thread?


Well I wouldn't complain!!!


----------



## Fluff

Ruddles said:


> I know this thread is over a decade old, but I wonder if there's any value in posting my code for exporting all the VBA code from Excel/Access/Word files?


Sounds like a good idea to me.


----------



## Ruddles

Spyros13 said:


> Well I wouldn't complain!!!


I'll start a new thread with the subject line *Exporting VBA code from Excel/Access/Word to text file*.  I'll drop you a PM with the link.  I just need to add a few comments in the code in case anyone wants to hack it about.  Couple of days max (he says).


----------



## Spyros13

Cool. Take your time. Knackered. It can wait. But I'd really appreciate it when / if you can.


----------



## grahamj42

I have 2 versions of the same spreadsheet from a 3rd party.

The visual changes are easy to see but I need to check if there are code changes.

The logicical process seems to be to export all code  from each app to a text file and the run the 2 text files through a file compare program.

Can this be done, please?

Graham


----------



## Ruddles

Done.  See Exporting VBA code from Excel/Access/Word to text file


----------

