+ Reply to Thread
Results 1 to 4 of 4

Code to write out all lines of code

  1. #1
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315

    Code to write out all lines of code

    The following code (C.Pearson's with a tweak or two to suit my purposes) serves me well to list all procedures in a module.

    Sub ListProcedures1nALLModulesInWBook()

    Dim VBCodeMod As CodeModule
    Dim vc As VBComponent
    Dim StartLine As Long
    Dim Msg As String
    Dim ProcName As String
    Cells.Clear

    k = 1
    For Each vc In ThisWorkbook.VBProject.VBComponents
    If vc.Type = vbext_ct_StdModule Or vc.Type = vbext_ct_ClassModule Or vc.Type = vbext_ct_MSForm Or vc.Type = vbext_ct_Document Then
    Set VBCodeMod = ThisWorkbook.VBProject.VBComponents(vc.Name).CodeModule
    With VBCodeMod
    StartLine = .CountOfDeclarationLines + 1
    Do Until StartLine >= .CountOfLines
    Msg = Msg & .ProcOfLine(StartLine, vbext_pk_Proc)
    StartLine = StartLine + _
    .ProcCountLines(.ProcOfLine(StartLine, _
    vbext_pk_Proc), vbext_pk_Proc)
    Cells(k, 1) = Msg
    Cells(k, 2) = vc.Name
    Cells(k, 3) = vc.Type
    Cells(k + 1, 4) = .ProcCountLines(.ProcOfLine(StartLine, vbext_pk_Proc), vbext_pk_Proc) & " Lines"
    k = k + 1
    Msg = ""
    Loop
    End With
    End If
    Next
    [a:j].Columns.AutoFit
    End Sub

    I want to take a step further and get a code to reproduce all the lines of the procedures (in a project modules) on one worksheet. I have serached in vain for this facility, having failed to re-tool Mr. Pearson's code to "list all lines" and not just the titles.

    A half-way house, is to export the modules as txt.files. But this approach is ungainly and ponderous as it sets up the arduous task of having to combine the codes from fragmented text files.

    I welcome anuy help.

    David

  2. #2
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    Hi all,

    I am forced to follow up my request for a possible look-in. It was apparently lost in heavy traffic when I first posted. Thanks in advance

  3. #3
    Dave Peterson
    Guest

    Re: Code to write out all lines of code

    Here's a post by Myrna Larson:

    http://groups.google.co.uk/group/mic...fd20fc89bdb78b

    or

    http://snipurl.com/gq95

    davidm wrote:
    >
    > Hi all,
    >
    > I am forced to follow up my request for a possible look-in. It was
    > apparently lost in heavy traffic when I first posted. Thanks in
    > advance
    >
    > --
    > davidm
    > ------------------------------------------------------------------------
    > davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
    > View this thread: http://www.excelforum.com/showthread...hreadid=392716


    --

    Dave Peterson

  4. #4
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    Many thanks Dave. That was kind of you. Maryna's Code will meet my needs with neccessary adaption to suit Excel. I can't fail to be amazed at the way and manner in which some nerds graft logic upon logic to solve problems. Fascinating stuff! Again, many thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1