Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / October 2006

Tip: Looking for answers? Try searching our database.

Determine active cell in a table using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob - 27 Oct 2006 20:40 GMT
Hi,

I need to determine what cell the cursor is in or what cell the user
selected using a popup menu or something. I've been able to get the current
slide, but I need to get more granular than that. Is there a command in VBA
to get that information as the user is in design mode?

Thanks much!
Rob
Steve Rindsberg - 28 Oct 2006 05:56 GMT
> I need to determine what cell the cursor is in or what cell the user
> selected using a popup menu or something. I've been able to get the current
> slide, but I need to get more granular than that. Is there a command in VBA
> to get that information as the user is in design mode?

If it's a PPT table, you can iterate through the .Cells collection and test
each cell's .Selected property

With .Table

For x = 1 to .Rows.Count
  For y = 1 to .Columns.Count
    If .Cell(x,y).Selected Then
      MsgBox "BINGO"

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Rob - 31 Oct 2006 14:29 GMT
So that seems to work if the cell is actually selected. Is there any way to
tell if the cursor is just sitting in the cell, not necessarily selected?

Also, is there a WithEvents statement that I can use to capture a user
clicking or moving from cell to cell in a table?

Thanks!
Rob

> > I need to determine what cell the cursor is in or what cell the user
> > selected using a popup menu or something. I've been able to get the current
[quoted text clipped - 16 lines]
> PPTools:  www.pptools.com
> ================================================
Steve Rindsberg - 31 Oct 2006 17:47 GMT
> So that seems to work if the cell is actually selected. Is there any way to
> tell if the cursor is just sitting in the cell, not necessarily selected?

Good question.  See below for your other question.
As to the first:

Sub TableTest()

Dim x As Long
Dim y As Long
Dim oSh As Shape
Dim oRng As TextRange

If ActiveWindow.Selection.Type = ppSelectionText Then
   ' The parent of the current text select is the shape's TextRange
   ' The parent of the TextRange is the shape itself
   ' We'll use that to get the name of the shape
   '  and compare that to the name of each cell in the table to see if we have a
match
   Set oRng = ActiveWindow.Selection.TextRange
   Set oSh = ActiveWindow.Selection.ShapeRange(1)
   
   With oSh.Table
       For x = 1 To .Rows.Count
           For y = 1 To .Columns.Count
               If .Cell(x, y).Shape.Name = oRng.Parent.Parent.Name Then
                   MsgBox "BINGO"
                   Debug.Print .Cell(x, y).Shape.Name
                   Debug.Print "Cell " & CStr(x) & ":" & CStr(y)
               End If
           Next
       Next
   End With

Else

   Set oSh = ActiveWindow.Selection.ShapeRange(1)

   With oSh.Table
       For x = 1 To .Rows.Count
           For y = 1 To .Columns.Count
               If .Cell(x, y).Selected Then
                   MsgBox "BINGO"
               End If
           Next
       Next
   End With

End If

End Sub

> Also, is there a WithEvents statement that I can use to capture a user
> clicking or moving from cell to cell in a table?

Make PPT respond to events
http://www.pptfaq.com/FAQ00004.htm

Changing cells in a PowerPoint table will trigger the selection change event.
If the table came from Word or Excel, then no.

> Thanks!
> Rob
[quoted text clipped - 19 lines]
> > PPTools:  www.pptools.com
> > ================================================

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Rob - 31 Oct 2006 21:04 GMT
Works like a champ! Thanks so much for your help!

> > So that seems to work if the cell is actually selected. Is there any way to
> > tell if the cursor is just sitting in the cell, not necessarily selected?
[quoted text clipped - 86 lines]
> PPTools:  www.pptools.com
> ================================================
Steve Rindsberg - 31 Oct 2006 22:28 GMT
> Works like a champ! Thanks so much for your help!

My pleasure ... I learned a new trick that I may be able to put to good use shortly.

> > > So that seems to work if the cell is actually selected. Is there any way to
> > > tell if the cursor is just sitting in the cell, not necessarily selected?
[quoted text clipped - 86 lines]
> > PPTools:  www.pptools.com
> > ================================================

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.