Select a table macro for word 2003

  • Thread starter Thread starter Johnnyboy5
  • Start date Start date
J

Johnnyboy5

When I try to record a macro to select a whole table table to be re-
sort it, the macro recording wont let me select the table.

Word 2003
 
You should be able to do it using the menu: Table | Select | Table.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

Thanks that worked - see my other post to sort that table by column
2 - nearly there

Many more thanks

Johnnyboy
 
Thanks that worked  - see my other post to sort that table by column
2  - nearly there

Many more thanks

Johnnyboy

Hi

thanks - sorted it out - might have been a bit basic but it works

Regards


Sub tableresort()

' this is too resort the table to John's domain layout

' Unprotect the file

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If

' go to the first row second column in table two

ActiveDocument.Tables(2).Cell(Row:=1, Column:=2).Range.Select
Selection.Collapse


Selection.SortAscending

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, Noreset:=True, Password:=""
End If

End Sub
 
Note that you don't have to select the table at all. You can call the Sort
method directly from the Range object associated with the table.

Dim r As Range
Set r = ActiveDocument.Tables(2).Range

'(etc.)

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"Johnnyboy5" wrote in message

Thanks that worked - see my other post to sort that table by column
2 - nearly there

Many more thanks

Johnnyboy

Hi

thanks - sorted it out - might have been a bit basic but it works

Regards


Sub tableresort()

' this is too resort the table to John's domain layout

' Unprotect the file

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If

' go to the first row second column in table two

ActiveDocument.Tables(2).Cell(Row:=1, Column:=2).Range.Select
Selection.Collapse


Selection.SortAscending

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, Noreset:=True, Password:=""
End If

End Sub
 
Note that you don't have to select the table at all. You can call the Sort
method directly from the Range object associated with the table.

Dim r As Range
Set r = ActiveDocument.Tables(2).Range

'(etc.)

--
Stefan Blom
Microsoft Word MVP

---------------------------------------------"Johnnyboy5"  wrote in message







Hi

thanks - sorted it out - might have been a bit basic but it works

Regards

Sub tableresort()

      ' this is too resort the table to John's domain layout

      '  Unprotect the file

If ActiveDocument.ProtectionType <> wdNoProtection Then
  ActiveDocument.Unprotect Password:=""
End If

' go to the first row second column in table two

   ActiveDocument.Tables(2).Cell(Row:=1, Column:=2).Range.Select
   Selection.Collapse

Selection.SortAscending

If ActiveDocument.ProtectionType = wdNoProtection Then
  ActiveDocument.Protect _
  Type:=wdAllowOnlyFormFields, Noreset:=True, Password:=""
End If

End Sub

Thanks - will give it a go.

Johnnyboy
 
Please post back with your findings! :-)

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"Johnnyboy5" wrote in message

Note that you don't have to select the table at all. You can call the Sort
method directly from the Range object associated with the table.

Dim r As Range
Set r = ActiveDocument.Tables(2).Range

'(etc.)

--
Stefan Blom
Microsoft Word MVP

---------------------------------------------"Johnnyboy5" wrote in
message







Hi

thanks - sorted it out - might have been a bit basic but it works

Regards

Sub tableresort()

' this is too resort the table to John's domain layout

' Unprotect the file

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If

' go to the first row second column in table two

ActiveDocument.Tables(2).Cell(Row:=1, Column:=2).Range.Select
Selection.Collapse

Selection.SortAscending

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, Noreset:=True, Password:=""
End If

End Sub

Thanks - will give it a go.

Johnnyboy
 
Back
Top