PDA

View Full Version : Change fill colour of current cell in table



Wandering
05-30-2013, 12:10 AM
Hello... His 'simple' one has me stumped!

I have a table on a slide with x columns and x rows. I want to the user to be able to click in a cell and hit alt+r and the fill colour will change to red. Ideally this would run in 'edit' mode as well as slideshow mode.

Any tips would be appreciated! Mike

John Wilson
05-30-2013, 01:59 AM
That's not simple at all.

There's no simple way to make the code run when you press a key (There are third party addins)

You also need to say which version you have.

In principle though loop through the cells and check the .Selected property.

With oTbl
For I = 1 To .Rows.Count
For J = 1 To .Columns.Count
If .Cell(I, J).Selected Then
'Change fill
End If
Next J
Next I
End With

Wandering
05-30-2013, 04:53 AM
Hi John, one of the hurdles I've come across is that the user doesn't 'select' the cell per se... The cursor is just in the cell.

I am running 2010... Mike

John Wilson
05-30-2013, 05:42 AM
If the cursor is in the cell in edit mode .Selected will still return True. There's no way in Slide Show mode to do this I can think of unless you place a transparent shape over each cell to trigger a different macro.

Wandering
05-30-2013, 11:45 PM
Thanks John, that worked really well!

Any tips on getting the shortcut key to work? Google searches seem to point towards a key press monitoring loop - is thus the only way??

Thanks again, Mike

John Wilson
05-31-2013, 08:15 AM
Shortcut keys are really tricky and yes a loop is the only way. Unless you really know what you are doing a total crash is likely. Shyam Pillai's site has details of using setTimer and killTimer to run a macro every .1 seconds which is the tricky part. If you go there be careful! Chirag Dahl at OfficeOne sells an AddIn which does the work for you but not free.

We used to offer a similar thing but it's just too dangerous in the wrong hands!