referencing cells in an embedded excel object with vba/vbscript

M

mstuehler

All,

I have a vbscript I'm using to build a dynamic powerpoint document. One of
the slides has a Powerpoint "table", and I can reference it's cells using
this syntax:

oSlide.Shapes("table").Cell(1, 1).Shape.TextFrame.TextRange.Text

However, my Powerpoint also has an embedded Excel Worksheet object, but I
can't figure out how to reference it (or cells within it), in VBA or vbscript.

Does anyone have any advice?

Many thanks in advance!

Cheers,
Matt Stuehler
 
S

Shyam Pillai

Matt,
Get a reference to the Excel Workbook and then proceed.

' -----------------------------------
Dim XLObj As Excel.Workbook
Dim oShape as PowerPoint.Shape

Set oShape = ActiveWindow.Selection.ShapeRange(1)
' Assumes that the selected shape is an excel object.

Set XLObj = oShape.OLEFormat.Object
Msgbox XLObj.Worksheets(1).Range("A1")
' Clean up
' -----------------------------------
 
M

mstuehler

Shyam,

Just wanted to thank you for your response - it answered my question
perfectly.

Cheers,
Matt
 
S

Shyam Pillai

You are welcome.

--
Regards
Shyam Pillai


mstuehler said:
Shyam,

Just wanted to thank you for your response - it answered my question
perfectly.

Cheers,
Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top