A
andreas
Dear Experts:
below macro applies a user-defined paragraph style to rows using an
input box. The macro is running fine.
But the input box also allows for entries such as 7,2 (comma because I
live in Germany). How do I have to re-write the code to only allow
integers as input box entries?
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub Tbl_BodyStyle()
Dim oRng As Word.Range
Dim oTbl As Word.Table
Dim AskRowNumber As String
Dim blnAsk As Boolean
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
Set oTbl = Selection.Tables(1)
Set oRng = oTbl.Range
blnAsk = True
Do While blnAsk
AskRowNumber = InputBox("Please indicate the first row number" &
vbCrLf & _
"to acquire user-defined paragraph style for table rows",
"style for rows x to " & oTbl.rows.Count)
If AskRowNumber = "" Then Exit Sub
If IsNumeric(AskRowNumber) Then
If AskRowNumber >= 1 And AskRowNumber <= Selection.Tables
(1).rows.Count Then blnAsk = False
End If
Loop
Set oTbl = Selection.Tables(1)
Set oRng = oTbl.Range
oRng.Start = oTbl.rows(AskRowNumber).Range.Start
oRng.Style = "user-defined-para-style"
Set oTbl = Nothing
Set oRng = Nothing
End Sub
below macro applies a user-defined paragraph style to rows using an
input box. The macro is running fine.
But the input box also allows for entries such as 7,2 (comma because I
live in Germany). How do I have to re-write the code to only allow
integers as input box entries?
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub Tbl_BodyStyle()
Dim oRng As Word.Range
Dim oTbl As Word.Table
Dim AskRowNumber As String
Dim blnAsk As Boolean
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
Set oTbl = Selection.Tables(1)
Set oRng = oTbl.Range
blnAsk = True
Do While blnAsk
AskRowNumber = InputBox("Please indicate the first row number" &
vbCrLf & _
"to acquire user-defined paragraph style for table rows",
"style for rows x to " & oTbl.rows.Count)
If AskRowNumber = "" Then Exit Sub
If IsNumeric(AskRowNumber) Then
If AskRowNumber >= 1 And AskRowNumber <= Selection.Tables
(1).rows.Count Then blnAsk = False
End If
Loop
Set oTbl = Selection.Tables(1)
Set oRng = oTbl.Range
oRng.Start = oTbl.rows(AskRowNumber).Range.Start
oRng.Style = "user-defined-para-style"
Set oTbl = Nothing
Set oRng = Nothing
End Sub