VBA: Add slides, late binding from MSWord 2002/PP 2002

  • Thread starter Thread starter Roger Whitehead
  • Start date Start date
R

Roger Whitehead

I'm trying to Add slides in a PP Presentation using Late Binding, from VBA
in a Word document. Reason for late binding is that I'm sending the document
to send the document to a user on Office 2003.

The line

Set sl = objPP.slides.Add(lng_Slide_Index, pplayoutblank)

trips an error:
"Slides.Add: Invalid enumeration value"

The variable 'lng_Slide_Index' is evaluating to 1, and is of type Long.
If I replace the variable with '1', I get the same error
If I replace the variable with '2', the error message tells me it's expectig
a value from 1 to 1.

Of course, if I set the Project Ref to include the PP object library, there
is no error.
 
I'm trying to Add slides in a PP Presentation using Late Binding, from VBA
in a Word document. Reason for late binding is that I'm sending the document
to send the document to a user on Office 2003.

The line

Set sl = objPP.slides.Add(lng_Slide_Index, pplayoutblank)

trips an error:
"Slides.Add: Invalid enumeration value"

The variable 'lng_Slide_Index' is evaluating to 1, and is of type Long.
If I replace the variable with '1', I get the same error
If I replace the variable with '2', the error message tells me it's expectig
a value from 1 to 1.

Of course, if I set the Project Ref to include the PP object library, there
is no error.

The problem isn't with lng_Slide_Index, it's with pplayoutblank - that's a
PowerPoint constant, not a Word or Office one. It's not defined in Word.
That's why it works with early binding - VBA then has a reference to the PPT OM
and constants and so on.

ppLayoutBlank = 12 in PowerPoint, so try

Set sl = objPP.slides.Add(lng_Slide_Index, 12)

or

Const ppLayoutBlank as Long = 12 ' this goes in the Declarations section
Set sl = objPP.slides.Add(lng_Slide_Index, pplayoutblank)
 
Of course........


Thanks Steve.
Regards
Roger

Steve Rindsberg said:
The problem isn't with lng_Slide_Index, it's with pplayoutblank - that's a
PowerPoint constant, not a Word or Office one. It's not defined in Word.
That's why it works with early binding - VBA then has a reference to the PPT OM
and constants and so on.

ppLayoutBlank = 12 in PowerPoint, so try

Set sl = objPP.slides.Add(lng_Slide_Index, 12)

or

Const ppLayoutBlank as Long = 12 ' this goes in the Declarations section
Set sl = objPP.slides.Add(lng_Slide_Index, pplayoutblank)


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
Back
Top