Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    238
    Thanks
    4
    Thanked 1 Time in 1 Post

    Is cursor in a table cell? (Word XP)

    I need to write an If Then Else macro where the If part has to start by determining whether or not the cursor is in a table cell.

    I can write the two actions but I have not been able to figure out how to determine whether or not the cursor is in a table cell. Can someone please help me with that bit?

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is cursor in a table cell? (Word XP)

    Not too sure on this, but I have this as a code snippet that (I presume) I have used in the past:

    ' Check if cursor is within a table cell

    If Selection.Information(wdWithInTable) Then
    ...
    Else
    ...
    End If

    Checking through the Word VBA help file gives more details on the possible arguments for the .Information property.

    Alan

  4. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    238
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Is cursor in a table cell? (Word XP)

    Perfect. Many thanks.

  5. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Is cursor in a table cell? (Word XP)

    There's a tiny risk that the insertion point will be at an end-of-row marker rather than inside a cell. If you need to be inside a cell, you'll want to check for this too:

    If Not Selection.Information(wdAtEndOfRowMarker) Then
    'do stuff that happens only inside a cell
    End If

  6. #5
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    238
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Is cursor in a table cell? (Word XP)

    Thanks for the additional information. I'll amend my code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •