Submitted via EggHeadCafe - Software Developer Portal of Choice
Rounded corner content editor web part with custom colors
http://www.eggheadcafe.com/tutorials/aspnet/462e29fe-2258-45c0-bd65-e67a1c071601/rounded-corner-content-ed.aspx
I think you're looking for something like the following:
'''remove bold face formatting from the first row
'''of every table except for the first table
Dim lTbl As Long
For lTbl = 2 To ActiveDocument.Tables.Count
ActiveDocument.Tables(lTbl).Rows(1).Range.Font.Bold = False
Next lTbl
HTH,
Dave
Thanks a lot the code works great. I am running into an error on a few of the tables.
Run-time error '5991';
Cannot access individual rows in this collection because the table has vertically merged cells.
None of the first row has vertically merged cells but later on in a few tables this is the case.
I was wondering if there was a known work around or how I would go about excluding individual tables in the macro. Thanks again for your help.
DaveLett wrote:
Hi Nick,I think you are looking for something like the following:'''remove
19-Jan-10
Hi Nick,
I think you are looking for something like the following:
HTH,
Dave
Previous Posts In This Thread:
Submitted via EggHeadCafe - Software Developer Portal of Choice
Build a C# NotifyIcon BalloonTip Scheduled Outlook Mail Checker
http://www.eggheadcafe.com/tutorials/aspnet/0235490b-a901-42b4-9eef-7dd29b6ae909/build-a-c-notifyicon-bal.aspx
Dim lTbl As Long
Dim lCl As Long
For lTbl = 2 To ActiveDocument.Tables.Count
With ActiveDocument.Tables(lTbl)
For lCl = 1 To .Range.Cells.Count
If .Range.Cells(lCl).RowIndex = 1 Then
.Range.Cells(lCl).Range.Font.Bold = True
End If
Next lCl
End With
Next lTbl
HTH,
Dave
I was wondering if you could recommend a quick way to modify the following code so it also starts on the second table, like was done with the bold code.
Dim myTable As Table
For Each myTable In ActiveDocument.Tables
myTable.Select
Selection.Style = ActiveDocument.Styles("Custom Table")
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = "12"
Selection.Rows.Alignment = wdAlignRowCenter
Next myTable
ActiveDocument.Repaginate
Thanks again for all your help.
DaveLett wrote:
Hi Nick,Yes, it is known issue with merged cells.
19-Jan-10
Hi Nick,
Yes, it is known issue with merged cells. You can try the following:
Dim lTbl As Long
Dim lCl As Long
For lTbl = 2 To ActiveDocument.Tables.Count
With ActiveDocument.Tables(lTbl)
For lCl = 1 To .Range.Cells.Count
If .Range.Cells(lCl).RowIndex = 1 Then
..Range.Cells(lCl).Range.Font.Bold = True
End If
Next lCl
End With
Next lTbl
HTH,
Dave
Previous Posts In This Thread:
Submitted via EggHeadCafe - Software Developer Portal of Choice
HOW TO GET RID OF THE "XXexmodulae.exe" Trojan
http://www.eggheadcafe.com/tutorials/aspnet/4d1b500f-23ce-4a5f-a18c-1d4261d01e86/how-to-get-rid-of-the-xx.aspx
Dim TableIndex As Long
For Each TableIndex = 2 To ActiveDocument.Tables.Count
ActiveDocument.Tables(TableIndex).Select
' then the formatting as before
Next TableIndex
Also, I'd recommend *not* selecting the table and using Selection to do the
formatting. VBA gives you access to things that aren't selected, with the
advantage that the document doesn't have to scroll and redraw the screen,
which is a slow operation. Sample code:
Dim TableIndex As Long
Dim myTable As Table
For Each TableIndex = 2 To ActiveDocument.Tables.Count
Set myTable = ActiveDocument.Tables(TableIndex)
With myTable
.Range.Style = ActiveDocument.Styles("Custom Table")
.Range.Font.Name = "Times New Roman"
.Range.Font.Size = 12
.Rows.Alignment = wdAlignRowCenter
End With
Next TableIndex
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
For TableIndex = 2 To ActiveDocument.Tables.Count
Jay Freedman wrote:
> Replace the For Each loop with one that uses the index into the Tables
> collection, and start at 2 -- something like this:
>
> Dim TableIndex As Long
> For Each TableIndex = 2 To ActiveDocument.Tables.Count
> ActiveDocument.Tables(TableIndex).Select
> ' then the formatting as before
> Next TableIndex
>
> Also, I'd recommend *not* selecting the table and using Selection to
> do the formatting. VBA gives you access to things that aren't
> selected, with the advantage that the document doesn't have to scroll
> and redraw the screen, which is a slow operation. Sample code:
>
> Dim TableIndex As Long
> Dim myTable As Table
> For Each TableIndex = 2 To ActiveDocument.Tables.Count
> Set myTable = ActiveDocument.Tables(TableIndex)
> With myTable
> .Range.Style = ActiveDocument.Styles("Custom Table")
> .Range.Font.Name = "Times New Roman"
> .Range.Font.Size = 12
> .Rows.Alignment = wdAlignRowCenter
> End With
> Next TableIndex
>
>