In the past there was not a set way to to create warning, caution or note
boxes in our documents. I have created the following macros to standardize
them. Is the a way to create a macro that will go through a existing document
and resize the table without removing the text thatâ??s in them? All of the old
boxes have the following as the first word:
Note in the Note Box
Caution in the Caution Box
Warning in the Warning Box


Sub NoteBox()
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
1, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:=wdAutoFitFixed
Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
RulerStyle:=wdAdjustNone
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:="NOTE"
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:=":"
Selection.TypeText Text:=" "
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.63)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With Selection.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = InchesToPoints(-0.63)
End With
End Sub


Sub CautionBox()
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
1, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:=wdAutoFitFixed
Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
RulerStyle:=wdAdjustNone
Selection.Tables(1).Borders.OutsideLineWidth = wdLineWidth225pt
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Bold = wdToggle
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="CAUTION"
Selection.Font.Underline = wdUnderlineNone
Selection.Font.Bold = wdToggle
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End Sub


Sub WarningBox()
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
1, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:=wdAutoFitFixed
Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
RulerStyle:=wdAdjustNone
Selection.Tables(1).Borders.OutsideLineWidth = wdLineWidth225pt
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Bold = wdToggle
Selection.Font.Underline = wdUnderlineSingle
Selection.TypeText Text:="WARNING"
Selection.Font.Underline = wdUnderlineNone
Selection.Font.Bold = wdToggle
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End Sub

RE: Table resizing by lf

lf
Sun Apr 15 16:28:02 CDT 2007

Based on your macros, I assume that all "boxes" consist of a table with only
one cell.
If this is correct, you may use the macro below to resize the tables. The
macro iterates through all tables in the active document. If the first word
is "NOTE", "CAUTION" or "WARNING" (in any combination of uppercase and
lowercase letters), the macro changes the left indent to 44 and the width to
423 (values taken from your macros) - the contents will not be changed. When
finished, the macro displays a message telling how many tables were resized.

NOTE: If there is any risk that other tables contain one of the words
"Note", "Caution" or "Warning" as the first word, you need to add more code
to check which tables to change.
Also note that you may need to adjust the macro, e.g. depending on the
settings applied to the existing tables.


Sub ResizeTables()
Dim oTable As Table
Dim n As Long 'use to count changed tables
n = 0
For Each oTable In ActiveDocument.Tables
With oTable
Select Case UCase(.Cell(1, 1).Range.Words.First)
Case "NOTE", "WARNING", "CAUTION"
'[insert code that makes the desired changes]
'[the following is based on your macros]
.Rows.LeftIndent = 44
.Columns(1).Width = 423
n = n + 1
End Select
End With
Next oTable
MsgBox "Finished adjusting " & n & " tables."
End Sub

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Fuzzhead" wrote:

> In the past there was not a set way to to create warning, caution or note
> boxes in our documents. I have created the following macros to standardize
> them. Is the a way to create a macro that will go through a existing document
> and resize the table without removing the text thatâ??s in them? All of the old
> boxes have the following as the first word:
> Note in the Note Box
> Caution in the Caution Box
> Warning in the Warning Box
>
>
> Sub NoteBox()
> ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
> 1, DefaultTableBehavior:=wdWord9TableBehavior,
> AutoFitBehavior:=wdAutoFitFixed
> Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
> RulerStyle:=wdAdjustNone
> Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
> RulerStyle:=wdAdjustNone
> If Selection.Font.Underline = wdUnderlineNone Then
> Selection.Font.Underline = wdUnderlineSingle
> Else
> Selection.Font.Underline = wdUnderlineNone
> End If
> Selection.TypeText Text:="NOTE"
> If Selection.Font.Underline = wdUnderlineNone Then
> Selection.Font.Underline = wdUnderlineSingle
> Else
> Selection.Font.Underline = wdUnderlineNone
> End If
> Selection.TypeText Text:=":"
> Selection.TypeText Text:=" "
> With Selection.ParagraphFormat
> .LeftIndent = InchesToPoints(0.63)
> .SpaceBeforeAuto = False
> .SpaceAfterAuto = False
> End With
> With Selection.ParagraphFormat
> .SpaceBeforeAuto = False
> .SpaceAfterAuto = False
> .FirstLineIndent = InchesToPoints(-0.63)
> End With
> End Sub
>
>
> Sub CautionBox()
> ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
> 1, DefaultTableBehavior:=wdWord9TableBehavior,
> AutoFitBehavior:=wdAutoFitFixed
> Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
> RulerStyle:=wdAdjustNone
> Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
> RulerStyle:=wdAdjustNone
> Selection.Tables(1).Borders.OutsideLineWidth = wdLineWidth225pt
> Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
> Selection.Font.Bold = wdToggle
> Selection.Font.Underline = wdUnderlineSingle
> Selection.TypeText Text:="CAUTION"
> Selection.Font.Underline = wdUnderlineNone
> Selection.Font.Bold = wdToggle
> Selection.TypeParagraph
> Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
> End Sub
>
>
> Sub WarningBox()
> ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
> 1, DefaultTableBehavior:=wdWord9TableBehavior,
> AutoFitBehavior:=wdAutoFitFixed
> Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
> RulerStyle:=wdAdjustNone
> Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
> RulerStyle:=wdAdjustNone
> Selection.Tables(1).Borders.OutsideLineWidth = wdLineWidth225pt
> Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
> Selection.Font.Bold = wdToggle
> Selection.Font.Underline = wdUnderlineSingle
> Selection.TypeText Text:="WARNING"
> Selection.Font.Underline = wdUnderlineNone
> Selection.Font.Bold = wdToggle
> Selection.TypeParagraph
> Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
> End Sub
>

RE: Table resizing by Fuzzhead

Fuzzhead
Mon Apr 16 12:08:01 CDT 2007

Thank you Lene, it worked great. This is going to save me hours of going
through each document and changing them.

Fuzzhead



"Lene Fredborg" wrote:

> Based on your macros, I assume that all "boxes" consist of a table with only
> one cell.
> If this is correct, you may use the macro below to resize the tables. The
> macro iterates through all tables in the active document. If the first word
> is "NOTE", "CAUTION" or "WARNING" (in any combination of uppercase and
> lowercase letters), the macro changes the left indent to 44 and the width to
> 423 (values taken from your macros) - the contents will not be changed. When
> finished, the macro displays a message telling how many tables were resized.
>
> NOTE: If there is any risk that other tables contain one of the words
> "Note", "Caution" or "Warning" as the first word, you need to add more code
> to check which tables to change.
> Also note that you may need to adjust the macro, e.g. depending on the
> settings applied to the existing tables.
>
>
> Sub ResizeTables()
> Dim oTable As Table
> Dim n As Long 'use to count changed tables
> n = 0
> For Each oTable In ActiveDocument.Tables
> With oTable
> Select Case UCase(.Cell(1, 1).Range.Words.First)
> Case "NOTE", "WARNING", "CAUTION"
> '[insert code that makes the desired changes]
> '[the following is based on your macros]
> .Rows.LeftIndent = 44
> .Columns(1).Width = 423
> n = n + 1
> End Select
> End With
> Next oTable
> MsgBox "Finished adjusting " & n & " tables."
> End Sub
>
> --
> Regards
> Lene Fredborg
> DocTools - Denmark
> www.thedoctools.com
> Document automation - add-ins, macros and templates for Microsoft Word
>
>
> "Fuzzhead" wrote:
>
> > In the past there was not a set way to to create warning, caution or note
> > boxes in our documents. I have created the following macros to standardize
> > them. Is the a way to create a macro that will go through a existing document
> > and resize the table without removing the text thatâ??s in them? All of the old
> > boxes have the following as the first word:
> > Note in the Note Box
> > Caution in the Caution Box
> > Warning in the Warning Box
> >
> >
> > Sub NoteBox()
> > ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
> > 1, DefaultTableBehavior:=wdWord9TableBehavior,
> > AutoFitBehavior:=wdAutoFitFixed
> > Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
> > RulerStyle:=wdAdjustNone
> > Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
> > RulerStyle:=wdAdjustNone
> > If Selection.Font.Underline = wdUnderlineNone Then
> > Selection.Font.Underline = wdUnderlineSingle
> > Else
> > Selection.Font.Underline = wdUnderlineNone
> > End If
> > Selection.TypeText Text:="NOTE"
> > If Selection.Font.Underline = wdUnderlineNone Then
> > Selection.Font.Underline = wdUnderlineSingle
> > Else
> > Selection.Font.Underline = wdUnderlineNone
> > End If
> > Selection.TypeText Text:=":"
> > Selection.TypeText Text:=" "
> > With Selection.ParagraphFormat
> > .LeftIndent = InchesToPoints(0.63)
> > .SpaceBeforeAuto = False
> > .SpaceAfterAuto = False
> > End With
> > With Selection.ParagraphFormat
> > .SpaceBeforeAuto = False
> > .SpaceAfterAuto = False
> > .FirstLineIndent = InchesToPoints(-0.63)
> > End With
> > End Sub
> >
> >
> > Sub CautionBox()
> > ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
> > 1, DefaultTableBehavior:=wdWord9TableBehavior,
> > AutoFitBehavior:=wdAutoFitFixed
> > Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
> > RulerStyle:=wdAdjustNone
> > Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
> > RulerStyle:=wdAdjustNone
> > Selection.Tables(1).Borders.OutsideLineWidth = wdLineWidth225pt
> > Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
> > Selection.Font.Bold = wdToggle
> > Selection.Font.Underline = wdUnderlineSingle
> > Selection.TypeText Text:="CAUTION"
> > Selection.Font.Underline = wdUnderlineNone
> > Selection.Font.Bold = wdToggle
> > Selection.TypeParagraph
> > Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
> > End Sub
> >
> >
> > Sub WarningBox()
> > ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
> > 1, DefaultTableBehavior:=wdWord9TableBehavior,
> > AutoFitBehavior:=wdAutoFitFixed
> > Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=44,
> > RulerStyle:=wdAdjustNone
> > Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=423,
> > RulerStyle:=wdAdjustNone
> > Selection.Tables(1).Borders.OutsideLineWidth = wdLineWidth225pt
> > Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
> > Selection.Font.Bold = wdToggle
> > Selection.Font.Underline = wdUnderlineSingle
> > Selection.TypeText Text:="WARNING"
> > Selection.Font.Underline = wdUnderlineNone
> > Selection.Font.Bold = wdToggle
> > Selection.TypeParagraph
> > Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
> > End Sub
> >