Microsoft Office Forums VBA to change the number of columns in a document at a page break.

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-09-2019, 11:52 AM
sts023 sts023 is offline VBA to change the number of columns in a document at a page break. Windows 7 64bit VBA to change the number of columns in a document at a page break. Office 2010
Novice
VBA to change the number of columns in a document at a page break.
 
Join Date: Apr 2019
Location: God's Own County
Posts: 11
sts023 is on a distinguished road
Default 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
Having created text in the columns, I now want to insert a page break (I can do that in VBA), then "merge" the second and third columns into one column, so col 1 is the same size as one of the original three columns, and column 2 is double the width of the original ones.
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
then set up a new two column page and adjust the column widths.
Any guidance on how to do this (or what I'm currently doing wrong!) would be gratefully accepted....
Reply With Quote
  #2  
Old 06-09-2019, 03:51 PM
macropod's Avatar
macropod macropod is online now VBA to change the number of columns in a document at a page break. Windows 7 64bit VBA to change the number of columns in a document at a page break. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,482
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

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
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to change the number of columns in a document at a page break. Word converts section break to page break before columns, does not insert column breaks eborda Word 1 03-24-2017 11:06 PM
VBA to change the number of columns in a document at a page break. 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
VBA to change the number of columns in a document at a page break. Page Break on Key Change bufferemail Mail Merge 7 05-11-2014 10:21 PM
VBA to change the number of columns in a document at a page break. Tabel of contents with three columns: Page number not below each other Lebber Word 5 01-22-2013 10:37 AM
VBA to change the number of columns in a document at a page break. Add Page Break to Document expatchic Word VBA 5 08-08-2012 04:16 PM


All times are GMT -7. The time now is 04:38 PM.


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