Re: Borders around a table cell
- From: Edward <Edward@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Feb 2009 18:08:01 -0800
You can use somthing like the following , I just applied the border color red
you can make other changes like border weight or differnt color.
Sub TableBorder()
Dim tbl As Table
Dim Mini As Integer
Dim Maxi As Integer
Dim Minj As Integer
Dim Maxj As Integer
Dim iflag As Boolean
Dim jflag As Boolean
Set tbl = ActiveWindow.Selection.ShapeRange(1).Table
For i = 1 To tbl.Rows.Count
For j = 1 To tbl.Columns.Count
If tbl.Cell(i, j).Selected Then
If iflag = False Then
Mini = i
Maxi = i
iflag = True
Else
Maxi = i
End If
If jflag = False Then
Minj = j
Maxj = j
jflag = True
Else
Maxj = j
End If
End If
Next
Next
If Mini > 0 Then
For y = Minj To Maxj
tbl.Cell(Mini, y).Borders(ppBorderTop).ForeColor.RGB = RGB(255, 0, 0)
tbl.Cell(Maxi, y).Borders(ppBorderBottom).ForeColor.RGB = RGB(255, 0, 0)
Next
For x = Mini To Maxi
tbl.Cell(x, Minj).Borders(ppBorderLeft).ForeColor.RGB = RGB(255, 0, 0)
tbl.Cell(x, Maxj).Borders(ppBorderRight).ForeColor.RGB = RGB(255, 0, 0)
Next
End If
End Sub
--
Best regards,
Edward
"John Svendsen" wrote:
Thank you both Steve and Shyam:.
Yup, the plot thickens as complexity increases :)
The problem I see with your examples is that you are able to detect all
selected cells and handle them individually. This is OK if you want to,
let's say, modify background color, but I think there's an issue if you want
to surround the entire selection with borders (using the examples the
borders in the middle of the selected cells would also be set, and not only
the countour of the selection (or have I lost it...)
Shyam, I've been testing your second example and all I get is "The specified
value is out of range" on line "With .GroupItems.Range(CellArray).Fill"
[I've created an 8x4 table and selected two cells)
Again, thanks to you both for your inputs - there's much to lear about
tables in PPT!
Rgds, JS
"Steve Rindsberg" <abuse@xxxxxxxxxxxxx> wrote in message
news:VA.00004a47.432389d3@xxxxxxxxxxxxxxxx
But I think I have a nastier issue, I need to surround two or more
adjacent
cells (TextRange fails when selecting 2+ cells), do you have any ideas on
how to go about this?
Yes, and thanks for asking. I've added an example to:
Working with PowerPoint tables
http://www.pptfaq.com/FAQ00790.htm
Short version:
If ActiveWindow.Selection.Type is ppSelectionShape, test to see if
Selection.ShapeRange(1).Type is 19 (table).
If so, iterate through the table's cells collection, testing each cell to
see
if its .Selected property is True. If so, it's a selected table cell.
Format
that sukkah.
Again thanks for your help!
Rgds, JS
"Steve Rindsberg" <abuse@xxxxxxxxxxxxx> wrote in message
news:VA.00004a44.4278be31@xxxxxxxxxxxxxxxx
In article <ecMaOB1lJHA.4448@xxxxxxxxxxxxxxxxxxxx>, John Svendsen
wrote:
Hi All:
I'm trying to write a VBA macro that will set all 4 borders around a
cell
in
a PPT table that is selected with a certain border color and line
thickness.
I've tried to record a macro when doin this manually but the recorded
macro
is empty!!! I've looked on VBA help but I don't seem to find how to
capture
teh selected cells and how to assing the border (I usually get help
from
a
recorded macro...).
This should help:
Working with PowerPoint tables
http://www.pptfaq.com/FAQ00790.htm
Don't expect your Works-Perfectly-In-2003 table code to work in
PowerPoint
2007, though. Tables+2007+VBA = BadlyBroken
==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/
PPTools add-ins for PowerPoint
http://www.pptools.com/
==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/
PPTools add-ins for PowerPoint
http://www.pptools.com/
- Follow-Ups:
- Re: Borders around a table cell
- From: John Svendsen
- Re: Borders around a table cell
- From: John Wilson
- Re: Borders around a table cell
- References:
- Borders around a table cell
- From: John Svendsen
- Re: Borders around a table cell
- From: Steve Rindsberg
- Re: Borders around a table cell
- From: John Svendsen
- Re: Borders around a table cell
- From: Steve Rindsberg
- Re: Borders around a table cell
- From: John Svendsen
- Borders around a table cell
- Prev by Date: Powerpoint interactive presentation
- Next by Date: RE: drag & drop/macros
- Previous by thread: Re: Borders around a table cell
- Next by thread: Re: Borders around a table cell
- Index(es):
Relevant Pages
|
Loading