Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cursor position on the current line 1

Status
Not open for further replies.

JSLUIS

Programmer
Aug 18, 2003
11
NL
Hi,

I’m making an application that is creating sentences. I’d like to know the position of the cursor on the current line, to decide whether I have to insert a carriage return.
Can anybody tell me if there is a property like CursorPosition or something like that; or another way to find out the position of the cursor on the current line ???

Thanks in advance,

Jaap Sluis
Holland
 
Code:
Function NumCharacter()

' just to make sure working with single selection point
   Selection.Collapse direction:=wdCollapseStart
  NumCharacter = (Selection.Range.Start - ActiveDocument.Bookmarks("\line").Range.Start)
End Function

will return the number of characters from the start of the current line (containing the Selection point), to the Selection point itself. This includes spaces in the count.

However, this may not help you in determining if you need a carriage return, or not.

How are you determining if it needs one or not?

If the line has been indented, say 40 charatcers, the relative position of the cursor (Selection point) to the start of the line will be the same as if there was no indent at all. However, the line break would come at a different relative number.

A carriage return should only be used, ever, to separate paragraphs. That is what it is for.

Could you clarify what it is you are trying to do?

Gerry
 
Hi JSLUIS,

I second Gerry's comments and don't understand why you want to be inserting carriage returns based on text position.

However, if you do want to do it, you might consider using the position on the page rather than the character. You can get this by:

Code:
[blue]Selection.Information(wdHorizontalPositionRelativeToPage)[/blue]

This will give you the position in points (72 points to the inch) from the left edge of the page.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
First off all: fumai and Tony thanks for your answer to my question, I hope your answers give me enough information to solve my problem.

Secondly, the reason to insert carriage returns is as follows:


We are making offers (mainly for stairs); these offers are built up with parts of sentences. For example:
2 Stairs with 12 steps, rise 180 mm, tread 240 mm, width 1200 mm, waist 120 mm, landing 1200 * 1400 mm € 1200,--
There are 2 demands; first: each part of the sentence (like tread 240 mm) should remain on the same line (is look strange if the mm part start on the other line) and second: the text should not intersect the imaginary column for the prices (who are aligned to the right of the document.

Greetings Jaap Sluis

 
Hi Jaap,

Have you considered using non-breaking spaces to ensure that, say, 1200 mm, always stays together. In Word, you enter it with Ctrl+Shift+SpaceBar and in code you can use Chr(160).

Also what about using a table to do your formatting - leaving a column on the right wide enough for your price?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Yes. This is a DESIGN issue more than anything else.

Gerry
 
No, I didn't know non-breaking spaces; I think this can help me al lot.

Thanks a lot.

Jaap
 
Boy I am glad that when I signed up here, I did not think I was good enough to list myself as Programmer. You guys must have headaches all the time.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top