tell the index number of the current table

setup

following the last post on the function fGetUserInpIdx (see more in here), how would the user know the index number of a, say, table? looks like a marco's called for.

solution

the plan

  1. tell if the cursor's inside a table. if not, ask to place inside one to check upon and run macro again.
  2. count the number of tables from doc start to cursor.
  3. pop the number up in a window.

programming language & module(s)

  • VBA

file preps

place the cursor inside the table whose index number we'd like to know.

variables to customize

none.

the script

vTblIdx
Sub vTblIdx()
If Selection.Information(wdWithInTable) Then
MsgBox "table Idx: " & ActiveDocument.Range(0, Selection.Start).Tables.Count
Else
MsgBox "please place the cursor inside a table and run again."
End If
End Sub

output

image.png

note to self

none.

Some rights reserved
Except where otherwise noted, content on this page is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.