![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
The code snippet below is causing my brain to overhead as I can't find the solution to problems
1. When the bold effect is applied to cells in the inserted table, it toggles the bold status of all other occurrences of the underlying style. 2. The inserted canvas always appears at the start of the previous page(hint, the insertion forces the caption to the following page). Code:
Sub sbInsertScientificResultsDiscussion()
Dim myRange As Range
Dim myTable As Table
Dim myCanvas As Shape
Set myRange = ActiveDocument.StoryRanges(wdMainTextStory)
With myRange
.Collapse direction:=wdCollapseEnd
.Style = ActiveDocument.Styles("Heading 1")
.InsertAfter Text:="Results and Discussion" & vbCrLf & vbcflf
.Collapse direction:=wdCollapseEnd
.Style = ActiveDocument.Styles("Table Text")
Set myTable = .Tables.Add(Range:=myRange, numrows:=5, numcolumns:=3, DefaultTableBehavior:=wdWord9TableBehavior)
myTable.Range.InsertCaption Label:="Table", Position:=wdCaptionPositionAbove, Title:=":" & vbTab & "Add table caption text" & vbCrLf
End With
With myTable
.Range.Style = ActiveDocument.Styles("Table Text")
.AllowAutoFit = False
.BottomPadding = 3
.TopPadding = 3
.LeftPadding = 6
.RightPadding = 6
.PreferredWidth = CentimetersToPoints(15.5)
With .Range
.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
Set myRange = ActiveDocument.StoryRanges(wdMainTextStory)
myRange.Collapse direction:=wdCollapseEnd
myRange.Style = ActiveDocument.Styles("Notes")
myRange.InsertAfter Text:="a." & vbTab & "This is a footnote a. to the table" & vbCrLf
myRange.InsertAfter Text:="b." & vbTab & "This is a footnote b. to the table" & vbCrLf
Set myRange = ActiveDocument.StoryRanges(wdMainTextStory)
myRange.Collapse direction:=wdCollapseEnd
myRange.Style = ActiveDocument.Styles("Body Text")
myRange.InsertAfter vbCrLf
myRange.Collapse direction:=wdCollapseEnd
Set myCanvas = ActiveDocument.Shapes.AddCanvas(Left:=100, Top:=100, Width:=CentimetersToPoints(15.5), Height:=200, Anchor:=myRange)
myCanvas.WrapFormat.Type = wdWrapInline
The styles used are just smaller versions of body text (10pt for table Text and 9pt for Notes text) I'd appreciate confirming if you have a similar problem or if my version of word is misbehaving. Last edited by slaycock; 12-07-2016 at 10:10 AM. Reason: putting code in code markers |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| When changing table style in Word 2010, font size seems to change but doesn't show in new tables | heartsoulliving | Word | 1 | 12-07-2016 05:17 PM |
After applying a title style, the row in a table doesn't break
|
Salix | Word | 6 | 05-05-2016 12:48 PM |
| Alignment problems with decimals using tables in Publisher 2013 | Beautiful Artist | Publisher | 0 | 02-24-2015 07:18 PM |
Problems with linked tables becoming corrupt
|
word_madness | Word | 2 | 02-10-2015 04:00 AM |
| Tables from Excel to Word: Problems | Guillo | Word | 0 | 11-19-2014 01:42 AM |