#1
|
|||
|
|||
VBA to change the number of columns in a document at a page break.
Can any kind soul offer guidance, please?
I use the following code to set up columns in a Word 2010 document Code:
Public Sub SetColsInWholeDoc(intCols As Integer) '####################################### '# Set the required number of columns. # '# N.B. The numcolumns parameter seems # '# to be the EXTRA columns (above # '# the basic 1), so we subtract # '# 1 from the User's specified # '# column count. # '####################################### '* '** Check it's a valid request. '* If intCols < 2 Then Exit Sub '* '** Now set the required column count. '* With Selection.Sections(1) With .PageSetup.TextColumns .SetCount NumColumns:=intCols - 1 .Add Spacing:=InchesToPoints(0.25), _ EvenlySpaced:=True End With glngColWidth = .PageSetup.TextColumns(1).Width gsngColWInches = PointsToInches(glngColWidth) ' MsgBox glngColWidth & " pts, " & gsngColWInches & " inches" End With End Sub 'SetColsInWholeDoc I know what the widths should be, it's the code to use I'm struggling with. Any clues, anyone? I've tried setting column widths, but when I do it seems to apply the new widths to all of the current document. I think I somehow need to sort of set a range which starts at the end of the current document (something like) Code:
Set rng = ActiveDocument.Content rng.Collapse Direction:=wdCollapseEnd Any guidance on how to do this (or what I'm currently doing wrong!) would be gratefully accepted.... |
#2
|
||||
|
||||
To change the column count you need to insert a Section break, not a page break, then apply the new column format to the new Section only.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word converts section break to page break before columns, does not insert column breaks | eborda | Word | 1 | 03-24-2017 11:06 PM |
Change page number in header on page x of y - y has too many pages | wpryan | Word VBA | 3 | 07-17-2015 07:04 AM |
Page Break on Key Change | bufferemail | Mail Merge | 7 | 05-11-2014 10:21 PM |
Tabel of contents with three columns: Page number not below each other | Lebber | Word | 5 | 01-22-2013 10:37 AM |
Add Page Break to Document | expatchic | Word VBA | 5 | 08-08-2012 04:16 PM |