none
Get cursor position RRS feed

Answers

  • Hi Eric,

    >> I need something that will work for Word 2007 as the Information object isn't available in that version.

    I am not sure what do you mean by “Information object isn't available in that version”. I made a research about Information object under Word 2007 Object model, I found it is available.

    # Selection.Information Property
    https://msdn.microsoft.com/en-us/library/bb148663(v=office.12).aspx
    # WdInformation Enumeration
    https://msdn.microsoft.com/en-us/library/bb213848(v=office.12).aspx

    I made a test with Selection.Information(wdFirstCharacterColumnNumber) with vba under Office 2013 and Office 2007, I could get the same result.

    Could you share us which issue you got when you use Selection.Information(wdFirstCharacterColumnNumber) under Word 2007? It would be helpful if you could share us steps and code to reproduce your issue.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, September 15, 2015 2:28 AM
  • Using Selection.Information(wdFirstCharacterColumnNumber) works well to determine whether the cursor is currently at the beginning of the line.  However, I need something that will work for Word 2007 as the Information object isn't available in that version.

    The Information object is available in Word 2007 - and for multiple Word versions before that.

    As for the task, for an alternative approach you could try:

    Sub Demo()
    Dim Rng As Range, SngHPos As Single, StrTxt As String
    Set Rng = Selection.Range
    With Rng
      .Collapse wdCollapseStart
      SngHPos = .Information(wdHorizontalPositionRelativeToPage)
      .MoveStart wdCharacter, -1
      .Collapse wdCollapseStart
      If .Information(wdHorizontalPositionRelativeToPage) < SngHPos Then
        StrTxt = " NOT "
      Else
        StrTxt = " "
      End If
    End With
    MsgBox "The Selection start is" & StrTxt & "at the start of the line."
    End Sub


    Cheers
    Paul Edstein
    [MS MVP - Word]


    Tuesday, September 15, 2015 3:52 AM

All replies

  • Hi Eric,

    >> I need something that will work for Word 2007 as the Information object isn't available in that version.

    I am not sure what do you mean by “Information object isn't available in that version”. I made a research about Information object under Word 2007 Object model, I found it is available.

    # Selection.Information Property
    https://msdn.microsoft.com/en-us/library/bb148663(v=office.12).aspx
    # WdInformation Enumeration
    https://msdn.microsoft.com/en-us/library/bb213848(v=office.12).aspx

    I made a test with Selection.Information(wdFirstCharacterColumnNumber) with vba under Office 2013 and Office 2007, I could get the same result.

    Could you share us which issue you got when you use Selection.Information(wdFirstCharacterColumnNumber) under Word 2007? It would be helpful if you could share us steps and code to reproduce your issue.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, September 15, 2015 2:28 AM
  • Using Selection.Information(wdFirstCharacterColumnNumber) works well to determine whether the cursor is currently at the beginning of the line.  However, I need something that will work for Word 2007 as the Information object isn't available in that version.

    The Information object is available in Word 2007 - and for multiple Word versions before that.

    As for the task, for an alternative approach you could try:

    Sub Demo()
    Dim Rng As Range, SngHPos As Single, StrTxt As String
    Set Rng = Selection.Range
    With Rng
      .Collapse wdCollapseStart
      SngHPos = .Information(wdHorizontalPositionRelativeToPage)
      .MoveStart wdCharacter, -1
      .Collapse wdCollapseStart
      If .Information(wdHorizontalPositionRelativeToPage) < SngHPos Then
        StrTxt = " NOT "
      Else
        StrTxt = " "
      End If
    End With
    MsgBox "The Selection start is" & StrTxt & "at the start of the line."
    End Sub


    Cheers
    Paul Edstein
    [MS MVP - Word]


    Tuesday, September 15, 2015 3:52 AM
  • My mistake, it is indeed available.  I was confusing it with other properties that I have been hoping to use with 2007.  I'm good to go - thanks!


    Eric Legault (MVP: Outlook)
    Co-author, Microsoft Office 2013 Professional Step-By-Step
    Try Outlook Touch!

    Wednesday, September 16, 2015 1:25 AM