LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Line position in code

Hi,

- Set a refererence to the MS VBA Extensibnility library:
menu Tools References, add 'Microsoft Visual Basic for Application
Extensilbility Library'
- in the search code, you can use the Find method or you can loop through
the lines, eg:
Dim v As VBProject
Dim c As CodeModule
Dim subName As String
Dim modName As String
Dim startline As Long, endline As Long

modName = "Module1"
subName = "test"

Set v = ThisWorkbook.VBProject
Set c = v.VBComponents(modName).CodeModule

startline = c.ProcStartLine(subName, vbext_pk_Proc)
endline = startline + c.ProcCountLines(subName, vbext_pk_Proc) - 1

'Is the string within the sub code?
MsgBox c.Find("Hello", startline, -1, endline, -1, False, False, False)

'Where is it?
'loop throught the Lines of c: c.Lines(i,1)

Check the ObjectBrowser/OnlineHelp for more details and other methods or
properties of the CodeModule object. Also, 'Find' can search for complex
patterns (Regular Expressions).

Regards,
Sebastien

"Ajit" wrote:

How can i find the number of line for a particular piece of code in a
procedure.
--
Ajit

 
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
Macro to change position of chart labels on line chart Shane Henderson[_2_] Charts and Charting in Excel 1 May 27th 11 09:31 AM
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Excel 2003 Line Chart - Switch Axis Position sot Charts and Charting in Excel 2 September 27th 07 01:12 PM
auto position of data labels in a line chart Nick Turner Charts and Charting in Excel 2 October 18th 05 11:43 PM
Line position in code Ajit Excel Programming 0 September 17th 04 03:49 PM


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