View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul C Paul C is offline
external usenet poster
 
Posts: 269
Default Reading the VBA code in a spreadsheet

Phil,

I think the line you are looking for is this
VBComponent.CodeModule.Lines(X,Y)
X=Start Line
Y=Number of Lines

This will output all code to a single spreadsheet

Sub ShowCode()


Set VBProj = ActiveWorkbook.VBProject
vcompcount = VBProj.VBComponents.Count
For A = 1 To vcompcount
Set VBComp = VBProj.VBComponents(A)
Set CodeMod = VBComp.CodeModule
For B = 1 To VBComp.CodeModule.countoflines
ActiveCell = VBComp.CodeModule.Lines(B, 1)
ActiveCell.Offset(1, 0).Select
Next B
Next A
End Sub
--
If this helps, please remember to click yes.


"Phil Hibbs" wrote:

Is there a way of accessing the code in a module in a spreadsheet? I
can get as far as the VBComponent.CodeModule but can't work out how to
access the actual code.

Phil Hibbs.
.