Hi

Someone gave me this macro recently but I have to change it every time I use
it on a different document.

Is there a way to get the macro to work on the table where the cursor is no
matter where the table is in the document.

A type of 'select active table where cursor is' command???

Thanks in advance.

Sub RandomPick()
'
' RandomPick Macro

Dim i As Long
Dim j As Long
i = ActiveDocument.Tables(3).Rows.Count ' table 3
Randomize
j = Int((i * Rnd) + 1)
ActiveDocument.Tables(3).Cell(j, 1).Select ' table 3

End Sub

RE: 'Select active table where cursor is' command????? by HelmutWeber

HelmutWeber
Wed Jun 22 08:47:04 CDT 2005

Hi Dave,

instead of
activeDocument.Tables(3)
use
selection.tables(1)
for first table in selection

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000

RE: 'Select active table where cursor is' command????? by DavidSisson

DavidSisson
Wed Jun 22 14:13:03 CDT 2005

http://word.mvps.org/FAQs/MacrosVBA/GetIndexNoOfPara.htm

Dim A as Long
A = ActiveDocument.Range(0, Selection.Tables(1).Range.End).Tables.Count

Change the Tables(3) to Tables(A)

Re: 'Select active table where cursor is' command????? by Dave

Dave
Wed Jun 22 08:57:21 CDT 2005

Works like a dream.

Thanks
"Helmut Weber" <HelmutWeber@discussions.microsoft.com> a écrit dans le
message de news: 36DB4122-00DE-4406-8653-3CACF7651B30@microsoft.com...
> Hi Dave,
>
> instead of
> activeDocument.Tables(3)
> use
> selection.tables(1)
> for first table in selection
>
> Greetings from Bavaria, Germany
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000