This is a multi-part message in MIME format.
------=_NextPart_000_003C_01C8B0FF.E7A6DA80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi. This is my first attempt to write a PowerPoint macro though I've =
written lots of Excel macros.
I have a few questions:
First, I'm trying to write a simple macro that will loop through all of =
the slides in the open PowerPoint presentation and identify each =
embedded Excel worksheet and activate it (the reason for this isn't =
important but the worksheet is connected to a database and I want to get =
fresh data). My macro looks like this:
Sub UpdateExcelShapes()
Dim oShape As Shape
Dim oPresentation As Presentation
Dim oSlide As Slide
Dim oSelection As Selection
=20
Set oPresentation =3D ActivePresentation
Set oSelection =3D Application.ActiveWindow.Selection
=20
For Each oSlide In oPresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type =3D msoEmbeddedOLEObject Then
If Left(oShape.OLEFormat.ProgID, 11) =3D "Excel.Sheet" Then
oSlide.Select
oShape.Select
oShape.OLEFormat.Activate
SendKeys "{ESC}"
End If
End If
Next oShape
Next oSlide
' If Not oSelection Is Nothing Then
' oSelection.Select
' End If
End Sub
When the macro gets to the oShape.Select statement I get the error =
message in the subject line of this posting. What does it mean and how =
do I fix it? I have no idea what view the message is referring to.
Second, I've written a similar little macro for Word. In that macro I =
needed the moral equivalent of the commented out code at the bottom of =
the macro to reselect whatever was originally selected before the macro =
started. Sadly in PowerPoint the Selection object doesn't have a Select =
method. Any suggestions?
Thirdly, if I can get this macro to work, I'd like to have it triggered =
whenever the PowerPoint presentation is opened. I was looking for the =
equivalent of the ThisWorkBook object that would have a Open event I =
could hook into but I see no such object in the VBE project explorer =
window. What am I missing?
TIA,
josh
------=_NextPart_000_003C_01C8B0FF.E7A6DA80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16640" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>Hi. This is my first attempt to write a PowerPoint macro =
though I've=20
written lots of Excel macros.</DIV>
<DIV> </DIV>
<DIV>I have a few questions:</DIV>
<DIV> </DIV>
<DIV>First, I'm trying to write a simple macro that will loop through =
all of the=20
slides in the open PowerPoint presentation and identify each embedded =
Excel=20
worksheet and activate it (the reason for this isn't important but the =
worksheet=20
is connected to a database and I want to get fresh data). My macro =
looks=20
like this:</DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Sub =
UpdateExcelShapes()<BR> Dim=20
oShape As =
Shape<BR> Dim=20
oPresentation As Presentation<BR> Dim=20
oSlide As =
Slide<BR> Dim=20
oSelection As Selection<BR> <BR> Set=20
oPresentation =3D ActivePresentation<BR> Set oSelection =3D=20
Application.ActiveWindow.Selection<BR> <BR> For Each =
oSlide In=20
oPresentation.Slides<BR> For Each oShape =
In=20
oSlide.Shapes<BR> If =
oShape.Type=20
=3D msoEmbeddedOLEObject=20
Then<BR>  =
; If=20
Left(oShape.OLEFormat.ProgID, 11) =3D "Excel.Sheet"=20
Then<BR>  =
; =20
oSlide.Select<BR> &n=
bsp; =20
oShape.Select<BR> &n=
bsp; =20
oShape.OLEFormat.Activate<BR> &n=
bsp; =20
SendKeys=20
"{ESC}"<BR> &n=
bsp;=20
End If<BR> End=20
If<BR> Next oShape<BR> Next=20
oSlide</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>' If Not oSelection =
Is Nothing=20
Then<BR>' =
oSelection.Select<BR>' End=20
If<BR>End Sub<BR></FONT></DIV>
<DIV>When the macro gets to the oShape.Select statement I get the error =
message=20
in the subject line of this posting. What does it mean and how do =
I fix=20
it? I have no idea what view the message is referring to.</DIV>
<DIV> </DIV>
<DIV>Second, I've written a similar little macro for Word. In that =
macro I=20
needed the moral equivalent of the commented out code at the bottom of =
the macro=20
to reselect whatever was originally selected before the macro =
started. =20
Sadly in PowerPoint the Selection object doesn't have a Select =
method. Any=20
suggestions?</DIV>
<DIV> </DIV>
<DIV>Thirdly, if I can get this macro to work, I'd like to have it =
triggered=20
whenever the PowerPoint presentation is opened. I was looking for =
the=20
equivalent of the ThisWorkBook object that would have a Open event I =
could hook=20
into but I see no such object in the VBE project explorer window. =
What am=20
I missing?</DIV>
<DIV> </DIV>
<DIV>TIA,</DIV>
<DIV> </DIV>
<DIV>josh</DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_003C_01C8B0FF.E7A6DA80--