Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-07-2016, 10:05 AM
slaycock slaycock is offline Two problems: Applying bold affects other tables and canvas doesn't appear at specified range Windows 7 64bit Two problems: Applying bold affects other tables and canvas doesn't appear at specified range Office 2013
Expert
Two problems: Applying bold affects other tables and canvas doesn't appear at specified range
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default Two problems: Applying bold affects other tables and canvas doesn't appear at specified range

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
<other stuff here that probably isn't relevant>

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
Reply With Quote
 



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
Two problems: Applying bold affects other tables and canvas doesn't appear at specified range 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
Two problems: Applying bold affects other tables and canvas doesn't appear at specified range 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft