Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Count lines code in workbook

I was wanting to count the lines of code in my workbook which has many
modules, I downloaded the count Loc program but can't seem to get it to run,
does anyone have some code to count lines of code in an entire workbook
including sheets and modules, possibly skipping comments? thanx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Count lines code in workbook

Use the following code

Public Function CountLines() As Long
Dim ovbp As VBProject
Dim ovbc As VBComponent
Dim lTotLines As Long
Set ovbp = ThisWorkbook.VBProject
For Each ovbc In ovbp.VBComponents
Debug.Print ovbc.Name, ovbc.CodeModule.CountOfLines
lTotLines = lTotLines + ovbc.CodeModule.CountOfLines
Next ovbc
CountLines = lTotLines
End Function

Make sure that the project References Visual Basic Extensibility library.

"Arnold Klapheck" wrote:

I was wanting to count the lines of code in my workbook which has many
modules, I downloaded the count Loc program but can't seem to get it to run,
does anyone have some code to count lines of code in an entire workbook
including sheets and modules, possibly skipping comments? thanx

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Count lines code in workbook

I cant find it under "Visual Basic Extensibility" or "Extensiblility"
library. Is it under a different name or do I have to import it?

thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Count lines code in workbook

It is called
Microsoft Visual Basic For Applications Extensibility n.n
The numbers at the end are not important. You go to Tools/References and
check on the above and hit OK.
Alok

"Arnold Klapheck" wrote:

I cant find it under "Visual Basic Extensibility" or "Extensiblility"
library. Is it under a different name or do I have to import it?

thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Count lines code in workbook

Thanks, that did it works great now.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Count lines code in workbook

Please help, what to do???
I tried that which was suggested in this thread and got this error:
Run-time error '1004': Programmatic access to Visual Basic Project is not
trusted
on this line in Alok's code:
Set ovbp = ThisWorkbook.VBProject

Thanks
Laura

"Alok" wrote:

It is called
Microsoft Visual Basic For Applications Extensibility n.n
The numbers at the end are not important. You go to Tools/References and
check on the above and hit OK.
Alok

"Arnold Klapheck" wrote:

I cant find it under "Visual Basic Extensibility" or "Extensiblility"
library. Is it under a different name or do I have to import it?

thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Count lines code in workbook

xl2002+ offers the user more security.

There's an option under: Tools|Macro|Security|Trusted Publishers

Check "trust access to Visual Basic Project"

This setting is a user-by-user setting. Your code can't change it.

laura_in_abq wrote:

Please help, what to do???
I tried that which was suggested in this thread and got this error:
Run-time error '1004': Programmatic access to Visual Basic Project is not
trusted
on this line in Alok's code:
Set ovbp = ThisWorkbook.VBProject

Thanks
Laura

"Alok" wrote:

It is called
Microsoft Visual Basic For Applications Extensibility n.n
The numbers at the end are not important. You go to Tools/References and
check on the above and hit OK.
Alok

"Arnold Klapheck" wrote:

I cant find it under "Visual Basic Extensibility" or "Extensiblility"
library. Is it under a different name or do I have to import it?

thanks


--

Dave Peterson
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
how i can count the dicontineued lines according to category wise Santosh Excel Worksheet Functions 1 September 23rd 08 03:24 PM
How to count grayed out lines in excel sfnbgirl Excel Discussion (Misc queries) 3 March 28th 08 08:06 PM
How to count lines in excel without selecting them chubbybat Excel Discussion (Misc queries) 2 March 5th 08 04:54 AM
Code to write out all lines of code davidm Excel Programming 3 August 5th 05 04:26 AM
how to display the count of lines found by autofilter? elaineb Excel Discussion (Misc queries) 1 April 6th 05 07:08 PM


All times are GMT +1. The time now is 06:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"