Cursor position in a module 
Author Message
 Cursor position in a module

How do I determine the module/procedure/line that my cursor is in?

If you are interested in how I have approached this, below is the stuff I
have tried but after playing for waaaay too long, I have determined that
there must be an easier way!!!
1. use sendkeys to insert some text that will be used as a bookmark (make it
unique by including the date and exact time)
2. go through the modules collection and use the Find method to locate the
text. There is a BIG problem here because the text doesn't want to actually
be inserted until after the code has finished running ... i.e. until the
Find that finished ... therefore the text is not found. The workaround I
have found, so far, involved opening a hidden form that does the sendkeys
(On Open) and the sets the timer to run a function that searches for the
text and sets some global variables. This works to a point, however there
are still problems ... which brings me back to ... do you know a better way?

Thanks,

Dennis



Thu, 02 Jan 2003 03:00:00 GMT  
 Cursor position in a module

Quote:

> How do I determine the module/procedure/line that my cursor is in?

    I'm thinking that when any code is running, including the code that makes
this determination .... the "cursor" (I assume you mean the I-Beam insert/edit
cursor - not the DAO Workspace.DefaultCursorDriver related cursor) doesn't
exist.  When no code is running, the cursor may or may not be in the source of a
code module.  So (I'm guessing) the "cursor" can't exist in the same time-space
continuum as running code.

Quote:

> If you are interested in how I have approached this, below is the stuff I
> have tried but after playing for waaaay too long, I have determined that
> there must be an easier way!!!
> 1. use sendkeys to insert some text that will be used as a bookmark (make it
> unique by including the date and exact time)

    I'm also assuming you're not talking about form or RecordSet Bookmarks......

Quote:

> 2. go through the modules collection and use the Find method to locate the
> text. There is a BIG problem here because the text doesn't want to actually
> be inserted until after the code has finished running ... i.e. until the
> Find that finished ... therefore the text is not found.

    What if the cursor was in the module that was performing this check?  In the
middle of a very important line.  And you inserted some text (let's say a
comment) that effectively caused a syntax error in the line, or modified the
functionality of the line enough to cause other errors.
    I think self-modifying code is silly and dangerous in *ANY* language (having
done my fair share of it), but in VBA, yuck!
Quote:
> The workaround I
> have found, so far, involved opening a hidden form that does the sendkeys
> (On Open) and the sets the timer to run a function that searches for the
> text and sets some global variables. This works to a point, however there
> are still problems ... which brings me back to ... do you know a better way?

> Thanks,

> Dennis



Thu, 02 Jan 2003 03:00:00 GMT  
 Cursor position in a module
Yes, by cursor I do mean the text insertion point.
Yes, bookmark is used in a generic sense ... it is not a recordset bookmark
it is simply a piece of text.
Yes, I realize that there may be some other text on the line when I insert
my "bookmark" that is why I mentioned that there must be a better solution.

Anyone know of a solution?

Dennis


Quote:


> > How do I determine the module/procedure/line that my cursor is in?

>     I'm thinking that when any code is running, including the code that
makes
> this determination .... the "cursor" (I assume you mean the I-Beam
insert/edit
> cursor - not the DAO Workspace.DefaultCursorDriver related cursor) doesn't
> exist.  When no code is running, the cursor may or may not be in the
source of a
> code module.  So (I'm guessing) the "cursor" can't exist in the same
time-space
> continuum as running code.

> > If you are interested in how I have approached this, below is the stuff
I
> > have tried but after playing for waaaay too long, I have determined that
> > there must be an easier way!!!
> > 1. use sendkeys to insert some text that will be used as a bookmark
(make it
> > unique by including the date and exact time)

>     I'm also assuming you're not talking about form or RecordSet
Bookmarks......

> > 2. go through the modules collection and use the Find method to locate
the
> > text. There is a BIG problem here because the text doesn't want to
actually
> > be inserted until after the code has finished running ... i.e. until the
> > Find that finished ... therefore the text is not found.

>     What if the cursor was in the module that was performing this check?
In the
> middle of a very important line.  And you inserted some text (let's say a
> comment) that effectively caused a syntax error in the line, or modified
the
> functionality of the line enough to cause other errors.
>     I think self-modifying code is silly and dangerous in *ANY* language
(having
> done my fair share of it), but in VBA, yuck!

> > The workaround I
> > have found, so far, involved opening a hidden form that does the
sendkeys
> > (On Open) and the sets the timer to run a function that searches for the
> > text and sets some global variables. This works to a point, however
there
> > are still problems ... which brings me back to ... do you know a better
way?

> > Thanks,

> > Dennis



Thu, 02 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Cursor position in a module

2. Cursor position

3. Find current cursor position in Word problem

4. How do I find cursor position inside textbox?

5. Cursor position in text box

6. Cursor position in Word

7. Getting Cursor position

8. Outlook body cursor position

9. how to get cursor position when double-clicked

10. Find and select from cursor position

11. Cursor Position

12. Determining cursor position in a table

 

 
Powered by phpBB® Forum Software