by Allen Wyatt
(last updated August 4, 2018)
Deena has a document that is formatted to use three columns. She would like a way to display and print, automatically, a column number at the top of each column. Thus, the columns on page 1 would be numbered 1 through 3, those on page 2 would be 4 through 6, etc.
There is no way to do this automatically, but a workaround is to create a macro that will print the document with column numbers in the page header. All you need to do is make sure that the header has tab stops set to match where you want the column numbers to appear.
Sub ColumnHeaders() Dim p As Long Dim tp As Long Dim c As Integer Dim tc As Integer Dim h As String Dim ch As String ' Get total pages tp = ActiveDocument.Content.ComputeStatistics(wdStatisticPages) ' Get number of columns tc = ActiveDocument.Sections(1).PageSetup.TextColumns.Count ' Save current header ch = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text For p = 1 To tp h = "" For c = 1 To tc h = h & Trim(Str(p + (c - 1) + (2 * p - 2))) & vbTab Next c h = Left(h, Len(h) - 1) ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = h ActiveDocument.PrintOut Range:=wdPrintFromTo, _ From:=Trim(Str(p)), To:=Trim(Str(p)) Next p If Len(ch) > 1 Then ' Restore previous header ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = ch Else ' There is no previous header ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete End If End Sub
The macro actually prints out each page of the document individually. It assumes there is only a single section in the document. The number of columns for that single section is determined, and then this count is used in putting together the header for each page. The header consists of the column numbers separated by tabs. The header is constructed for each page, and then each page is printed.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12826) applies to Microsoft Word 2007, 2010, 2013, and 2016.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Columns can be an integral part of your document layout. In some instances you may want Word to insert a vertical line ...Discover More
Users of WordPerfect know what parallel columns are. There is no such capability in Word, but there are ways you can ...Discover More
If you need to change the number of columns used in a portion of your document, it's easy to do when you use the Columns ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.