A
andreas
Dear Experts:
I created a macro that allows the user to format the Table of Contents
by using InputBoxes.
The user can fill in a value into the dialog box "Please indicate the
left indent in centimeters". The value he/she indicates is then
transferred to the "With ... " line.
I then want the the user to see the previously filled in value (in
centimeters) whenever he re-runs the macro. It works fine with the
following macro lines (only part of the whole macro) but as soon as I
hit the Cancel Button on the InputBox form it does not exit the sub but
takes me to the Error Message on the bottom. How do I have to rewrite
the code that - when the user hits the Cancel Button on the inputbox
form - the macro is exited?
Dim LeftIndent As Single
LeftIndent =
Round(PointsToCentimeters(ActiveDocument.Styles_("Custom_TOC_Style").ParagraphFormat.LeftIndent),
1)
On Error GoTo Mistake
'since I declared the LefIndent as single, entering character(s) or
blank(s) causes the macro to jump to the Error Message below
LeftIndent = InputBox("Please indicate the left Indent", "Indent Size",
LeftIndent)
If LeftIndent <= 1.3 Then
MsgBox "No values below 1.3 are allowed. "
Exit Sub
End If
With ActiveDocument.Styles("Custom_TOC_Style").ParagraphFormat
.LeftIndent = CentimetersToPoints(LeftIndent)
.FirstLineIndent = CentimetersToPoints(-LeftIndent)
End With
Exit Sub
Mistake:
MsgBox "only numbers are allowed, no blanks or characters",
vbInformation
End Sub
Help is appreciated. Thanks in advance
Andreas
I created a macro that allows the user to format the Table of Contents
by using InputBoxes.
The user can fill in a value into the dialog box "Please indicate the
left indent in centimeters". The value he/she indicates is then
transferred to the "With ... " line.
I then want the the user to see the previously filled in value (in
centimeters) whenever he re-runs the macro. It works fine with the
following macro lines (only part of the whole macro) but as soon as I
hit the Cancel Button on the InputBox form it does not exit the sub but
takes me to the Error Message on the bottom. How do I have to rewrite
the code that - when the user hits the Cancel Button on the inputbox
form - the macro is exited?
Dim LeftIndent As Single
LeftIndent =
Round(PointsToCentimeters(ActiveDocument.Styles_("Custom_TOC_Style").ParagraphFormat.LeftIndent),
1)
On Error GoTo Mistake
'since I declared the LefIndent as single, entering character(s) or
blank(s) causes the macro to jump to the Error Message below
LeftIndent = InputBox("Please indicate the left Indent", "Indent Size",
LeftIndent)
If LeftIndent <= 1.3 Then
MsgBox "No values below 1.3 are allowed. "
Exit Sub
End If
With ActiveDocument.Styles("Custom_TOC_Style").ParagraphFormat
.LeftIndent = CentimetersToPoints(LeftIndent)
.FirstLineIndent = CentimetersToPoints(-LeftIndent)
End With
Exit Sub
Mistake:
MsgBox "only numbers are allowed, no blanks or characters",
vbInformation
End Sub
Help is appreciated. Thanks in advance
Andreas