A
andreas
Dear Experts:
below macro - which is running just fine - performs the following
tasks:
1. Ask the user to input a row number
2. The entered row number and all subsequent row numbers till the last
one will acquire a user defined paragraph style.
Now here comes my additional requirement to be incorporated into the
code:
The input is to be restricted to ....
1) only numeric values
2) should range only between 1 and the total number of rows of the
currently selected table
3) figures entered that are not within that range should throw an
error message (Input not within the range of row numbers 1 to total
count of rows (e.g. 20). After pressing ok, the input box is to
reappear.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub Tbl_BodyStyle_SelectRow()
Dim oRng As Word.range
Dim oTbl As Word.Table
Dim AskRowNumber As String
If Not Selection.Information(wdWithInTable) Then
MsgBox "Please place the cursor into the table", _
vbOKOnly + vbCritical, "User-defined style for selected table
rows"
Exit Sub
End If
AskRowNumber = InputBox("Please indicate the first row number" &
vbCrLf & _
"to acquire <Dis_Tbl_Body_Text>", "style for rows x to last one")
Set oTbl = Selection.Tables(1)
Set oRng = oTbl.range
oRng.Start = oTbl.rows(AskRowNumber).range.Start
oRng.Style = "Dis_Tbl_Body_Text"
Set oTbl = Nothing
Set oRng = Nothing
End Sub
below macro - which is running just fine - performs the following
tasks:
1. Ask the user to input a row number
2. The entered row number and all subsequent row numbers till the last
one will acquire a user defined paragraph style.
Now here comes my additional requirement to be incorporated into the
code:
The input is to be restricted to ....
1) only numeric values
2) should range only between 1 and the total number of rows of the
currently selected table
3) figures entered that are not within that range should throw an
error message (Input not within the range of row numbers 1 to total
count of rows (e.g. 20). After pressing ok, the input box is to
reappear.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub Tbl_BodyStyle_SelectRow()
Dim oRng As Word.range
Dim oTbl As Word.Table
Dim AskRowNumber As String
If Not Selection.Information(wdWithInTable) Then
MsgBox "Please place the cursor into the table", _
vbOKOnly + vbCritical, "User-defined style for selected table
rows"
Exit Sub
End If
AskRowNumber = InputBox("Please indicate the first row number" &
vbCrLf & _
"to acquire <Dis_Tbl_Body_Text>", "style for rows x to last one")
Set oTbl = Selection.Tables(1)
Set oRng = oTbl.range
oRng.Start = oTbl.rows(AskRowNumber).range.Start
oRng.Style = "Dis_Tbl_Body_Text"
Set oTbl = Nothing
Set oRng = Nothing
End Sub