LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Determine procedure name at cursor?

Thanks Myrna, I'll give this a go!

Myrna Larson wrote:
There are a couple of methods that you need for this: GetSelection, and
ProcOfLine, both of which are in the VBIDE library. The following is extracte
from Help for the two methods. You can get the line number from the StartLine
argument of the GetSelection method, and if you supply that to GetProcOfLine,
it will return the procedure name.

The following worked for me from the immediate window:

application.vbe.activecodepane.getselection L1&,C1&,L2&,C2&
debug.print application.VBE.activecodepane _
.codemodule.ProcOfLine(L1&,vbext_pk_Proc)






GetSelection Method
Returns the selection in a code pane.
Syntax
object.GetSelection(startline, startcol, endline, endcol)


ProcOfLine Property
Returns the name of the procedure that the specified line is in.
Syntax
object.ProcOfLine(line, prockind) As String

On Tue, 15 Mar 2005 15:47:49 -0000, "Amit Shanker"
wrote:


Hi,

Is there a way to programmatically determine the name of the
procedure/function where the cursor is currently located? To explain,
suppose a regular VBA module has 3 procedures in it (Foo1, Foo2 & Foo3); my
query is if I click anywhere within Foo2 in the code module window, is there
any way to determine that I have my cursor currently within Foo2?

The reason I need to determine this is to click within any procedure, and
then call this procedure from another one using the Application.Run method.

Thanks,
Amit



 
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 to determine cursor location? Dan Excel Discussion (Misc queries) 4 March 12th 09 03:11 PM
Function to determine current cursor position? Dan Excel Worksheet Functions 1 March 12th 09 02:56 PM
move cursor on one sheet moves cursor on all sheets tdworden Excel Discussion (Misc queries) 2 July 22nd 07 10:50 PM
Can I change the "white cross" cursor in Excel to another cursor? KFEagle Excel Discussion (Misc queries) 1 May 3rd 05 08:01 PM


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