Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
Hopeless Idiot
VBA to change the number of columns in a document at a page break.
 
Join Date: Apr 2019
Location: God's Own County
Posts: 26
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
 



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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:57 AM.


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