Finding character/cursor position

I

info

I'm trying to write a macro that repeatedly enters a character ("-")
from the current cursor "column" (the numer shown as "Col" on the
status bar, not the screen position of the mouse) until it reaches a
specific position (eg, 80). So if I'm on Col 10, it'd draw a line of
70 dashes until it reaches column 80. (This macro is really for
VisualStudio, where I want to draw lines while commenting code, but
the VBA concept should be the same.)

So it'd be something like:

Sub _BarEqual()
Dim iCurPos As Int16
iCurPos = GET_CURRENT_CURSOR_COLUMN ' I don't know how to get
this.
Dim iDrawCount = 80 - iCurPos

For i = 1 To iDrawCount
DTE.ActiveDocument.Selection.Text = "-"
Next
End Sub

Thanks!
 
J

Jay Freedman

In Word, the number iCurPos would be obtained from the function

Selection.Information(wdFirstCharacterColumnNumber)

But wdFirstCharacterColumnNumber is a member of the WdInformation
enumeration, which is defined only in the Word object model. I don't think
it's applicable to Visual Studio macros. For that matter, the .Information
property may not be available there, either.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
I

info

In Word, the number iCurPos would be obtained from the function

  Selection.Information(wdFirstCharacterColumnNumber)

But wdFirstCharacterColumnNumber is a member of the WdInformation
enumeration, which is defined only in the Word object model. I don't think
it's applicable to Visual Studio macros. For that matter, the .Information
property may not be available there, either.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroupso
all may benefit.









- Show quoted text -

Thanks Jay, but you're right. The object models are different in Word
and VS. I'm a C++ developer and figured I could write this simple
macro, but I guess it's more than it appears...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top