Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2013, 03:40 AM
lsmcal1984 lsmcal1984 is offline Combining two pieces of VBA to create caption field above table Windows XP Combining two pieces of VBA to create caption field above table Office 2003
Novice
Combining two pieces of VBA to create caption field above table
 
Join Date: Aug 2013
Posts: 18
lsmcal1984 is on a distinguished road
Default Combining two pieces of VBA to create caption field above table

Dear all,

I have inherited two macros that are used to generate a caption field at the top of a table in each document. It does this by inserting a row above the current row, however there is a caveat (explained after the code):

Code:
 
Sub InsCptnRw()
Selection.InsertRowsAbove 1
Selection.Cells.Merge
With Selection.Cells
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorAutomatic
End With
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = 7810048
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
End Sub
And:



Code:
 
Sub HdrRw()
With Selection.Cells
With .Shading
.Texture = wdTextureNone
.BackgroundPatternColor = RGB(40, 70, 111)
End With
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = 7810048
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = 7810048
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth025pt
.Color = 7810048
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
'.LineWidth = wdLineWidth05pt
.Color = RGB(255, 255, 255)
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
End Sub
When this code is used, a row is created with text in caption style. However, the row below it appears in white (as the previous top row in the table is white). It would be great to create code that inserts this top row as caption style text in black and the row below converts to white text.

This is much appreciated and I hope it's clear.
Reply With Quote
  #2  
Old 08-16-2013, 04:12 AM
lsmcal1984 lsmcal1984 is offline Combining two pieces of VBA to create caption field above table Windows XP Combining two pieces of VBA to create caption field above table Office 2003
Novice
Combining two pieces of VBA to create caption field above table
 
Join Date: Aug 2013
Posts: 18
lsmcal1984 is on a distinguished road
Default

It might be better to combine all this into one piece of code:

Create a table with:

Top row set as caption row, second row set with shading and white text, third row set blank.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Field not showing in Pivot Table Field List kmcovington Excel 0 10-26-2012 10:14 AM
Combining two pieces of VBA to create caption field above table Combining Text from Table Cells robmorleyuk Word 1 11-01-2011 07:24 AM
Combining two pieces of VBA to create caption field above table How to make the Caption and its text have the same width as the table? Jamal NUMAN Word 1 04-24-2011 06:44 PM
Combining two pieces of VBA to create caption field above table Caption and Table of Figures issue reece22345 Word 3 04-15-2011 12:18 AM
Spacing between table and caption EtienneOBrien Word Tables 0 12-27-2008 01:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:06 AM.


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