Re: Borders around a table cell



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/




.



Relevant Pages

  • Re: Borders around a table cell
    ... you can make other changes like border weight or differnt color. ... Dim Mini As Integer ... selected cells and handle them individually. ... to surround the entire selection with borders (using the examples the ...
    (microsoft.public.powerpoint)
  • Re: Borders around a table cell
    ... selected cells and handle them individually. ... to surround the entire selection with borders (using the examples the ... selected area, set the top border on the top, left border on the leftmost cells ... Working with PowerPoint tables ...
    (microsoft.public.powerpoint)
  • Re: Borders around a table cell
    ... Dim Icol As Integer ... selected cells and handle them individually. ... to surround the entire selection with borders (using the examples the ...
    (microsoft.public.powerpoint)
  • Re: Search for #s in range
    ... > Dim iRow As Long, iColumn As Long, dblLastRow As Long ... > 'Check for duplicate Worksheet name ... > 'Identify the cells with formulas and values in them ... > With Selection ...
    (microsoft.public.excel.programming)
  • Re: Duplicate a picture image into multiple cells
    ... It use a selection. ... Just select all cells starting with your bitmap and then run this macro ... Dim rngSel As Range ... For Each myshape In ActiveSheet.Shapes ...
    (microsoft.public.excel.programming)

Loading