View Single Post
 
Old 12-07-2016, 02:09 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,359
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The change vis-à-vis the bold effect is probably because you've defined the 'Table Text' Style with the 'automatically update' attribute.

I'm not seeing the errant canvas behaviour, but that may be due to not having the same page layout & content you're starting with.

The following works for me:
Code:
Sub sbInsertScientificResultsDiscussion()
Application.ScreenUpdating = False
With ActiveDocument
  With .Range
    .InsertAfter vbCr & "Results and Discussion" & vbCr
    .Paragraphs.Last.Previous.Style = "Heading 1"
    .Tables.Add Range:=.Characters.Last, numrows:=5, numcolumns:=3, _
        DefaultTableBehavior:=wdWord9TableBehavior
    With .Tables(.Tables.Count)
      .Range.InsertCaption Label:="Table", Position:=wdCaptionPositionAbove, _
          Title:=":" & vbTab & "Add table caption text" & vbCr
      .AllowAutoFit = False
      .BottomPadding = 3
      .TopPadding = 3
      .LeftPadding = 6
      .RightPadding = 6
      .PreferredWidth = CentimetersToPoints(15.5)
      With .Range
        .Style = "Table Text"
        .Cells.VerticalAlignment = wdCellAlignVerticalCenter
        .Cells(1).Range.Text = "Table Text + local effect: bold"
        .Cells(1).Range.Font.Bold = True
        .Cells(4).Range.Text = "Table text + local effect: Align left"
        .Cells(4).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
        .Cells(5).Range.Text = "Table Text is centered by default"
      End With
    End With
    .Paragraphs.Last.Style = "Notes"
    .InsertAfter Text:="a." & vbTab & "This is a footnote a. to the table" & vbCr
    .InsertAfter Text:="b." & vbTab & "This is a footnote b. to the table" & vbCr
    .Paragraphs.Last.Style = "Body Text"
  End With
  .Shapes.AddCanvas Left:=0, Top:=0, Anchor:=.Range.Characters.Last, _
      Width:=CentimetersToPoints(15.5), Height:=CentimetersToPoints(7.06)
  .Shapes(.Shapes.Count).WrapFormat.Type = wdWrapInline
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote