Defining Slide Layout in VBA using a variable

K

koldkompress

Hi all,

I'm using VBA to parse an XML file into a powerpoint. I've got an
attribute on my Slide node called "layout". When I come to create a
slide I use this code:

' For each subject within the presentation
For Each SubjNode In PresNode.childNodes

' For each slide within that subject..
For Each SlideNode In SubjNode.childNodes

'Create that slide
Set PPSlide = PPPres.Slides.Add(PPPres.Slides.Count + 1,
SlideNode.getAttribute("layout"))

If you note the last line of code, it has the slides.add with the
layout attribute from the SlideNode. However, I get a "Type Mismatch"
even though a Debug.Print SlideNode.getAttribute("layout") displays
the correct layout (ppLayoutText)

Thanks

Michael
 
C

Chirag

getAttribute() returns a string but the second argument to Slides.Add() is
an enum or an int. You need to convert the ppLayout* constants that you get
as string to their int values and pass it as second argument.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
K

KoldKay

getAttribute() returns a string but the second argument to Slides.Add() is
an enum or an int. You need to convert the ppLayout* constants that you get
as string to their int values and pass it as second argument.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html











- Show quoted text -

Hey Chirag,

Thanks, that's really done the trick. All I have to do now is figure
out all the numerical IDs and then use my database to convert them.

Thanks again

Michael
 
K

KoldKay

Hey Chirag,

Thanks, that's really done the trick. All I have to do now is figure
out all the numerical IDs and then use my database to convert them.

Thanks again

Michael- Hide quoted text -

- Show quoted text -

I know I'm replying to myself, but if anyone needs references for
these, here's my rough guide:

1 = Title with subtitle
2 = title + text
3 = Title + Two Text
4 = Title + Table
5 = Title + text + chart
6 = Title + Chart + Text
7 = Title + Diagram
8 = Title + Chart
9 = Title + text + Clipart
10 = Title + Clipart + Text
11 = Title [At top] only
12 = Blank
13 = Title + text + content
14 = Title + Content + text
15 = Large Content
16 = Title + Content
17 = Title + Text + Media Clip
18 = Title + Media Clip + Text
19 = Title + Content + text
20 = Title + Text + Content
21 = Title + Text + Content + Content
22 = Title + Content + Content + text
23 = Title + Content + Content + Text [Vertical]
24 = Title + Content + Content + Content + Content
25 = Title + Side Text
26 = Title + Clipart + Side Text
27 = Side Title + Side Text
28 = Side Title + Sidetext + Chart
29 = Title + Content + Content
30 = Title + Content + Small content + Small Content
31 = Title + Small Content + small Content + Content

Thanks

Michael
 
C

Chirag

KoldKay said:
Hey Chirag,

Thanks, that's really done the trick. All I have to do now is figure
out all the numerical IDs and then use my database to convert them.

Thanks again

Michael- Hide quoted text -

- Show quoted text -

I know I'm replying to myself, but if anyone needs references for
these, here's my rough guide:

1 = Title with subtitle
2 = title + text
3 = Title + Two Text
4 = Title + Table
5 = Title + text + chart
6 = Title + Chart + Text
7 = Title + Diagram
8 = Title + Chart
9 = Title + text + Clipart
10 = Title + Clipart + Text
11 = Title [At top] only
12 = Blank
13 = Title + text + content
14 = Title + Content + text
15 = Large Content
16 = Title + Content
17 = Title + Text + Media Clip
18 = Title + Media Clip + Text
19 = Title + Content + text
20 = Title + Text + Content
21 = Title + Text + Content + Content
22 = Title + Content + Content + text
23 = Title + Content + Content + Text [Vertical]
24 = Title + Content + Content + Content + Content
25 = Title + Side Text
26 = Title + Clipart + Side Text
27 = Side Title + Side Text
28 = Side Title + Sidetext + Chart
29 = Title + Content + Content
30 = Title + Content + Small content + Small Content
31 = Title + Small Content + small Content + Content

These are documented at (look for PpSlideLayout):
http://msdn2.microsoft.com/en-us/library/aa211582(office.11).aspx

Microsoft Office PowerPoint 2007 introduces a few more:
ppLayoutCustom = 32
ppLayoutSectionHeader 33
ppLayoutComparison = 34
ppLayoutContentWithCaption = 35
ppLayoutPictureWithCaption = 36

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
K

Kathy Jacobs

You know... One of us should mark this down and send it Mr. Rindsberg so
that it gets FAQed... Awe - heck - I am just going to email it to him and
hope he sees it.

--
Kathy Jacobs, Microsoft MVP OneNote and PowerPoint
Author of Kathy Jacobs on PowerPoint
Get PowerPoint and OneNote information at www.onppt.com

I believe life is meant to be lived. But:
if we live without making a difference, it makes no difference that we lived

KoldKay said:
Hey Chirag,

Thanks, that's really done the trick. All I have to do now is figure
out all the numerical IDs and then use my database to convert them.

Thanks again

Michael- Hide quoted text -

- Show quoted text -

I know I'm replying to myself, but if anyone needs references for
these, here's my rough guide:

1 = Title with subtitle
2 = title + text
3 = Title + Two Text
4 = Title + Table
5 = Title + text + chart
6 = Title + Chart + Text
7 = Title + Diagram
8 = Title + Chart
9 = Title + text + Clipart
10 = Title + Clipart + Text
11 = Title [At top] only
12 = Blank
13 = Title + text + content
14 = Title + Content + text
15 = Large Content
16 = Title + Content
17 = Title + Text + Media Clip
18 = Title + Media Clip + Text
19 = Title + Content + text
20 = Title + Text + Content
21 = Title + Text + Content + Content
22 = Title + Content + Content + text
23 = Title + Content + Content + Text [Vertical]
24 = Title + Content + Content + Content + Content
25 = Title + Side Text
26 = Title + Clipart + Side Text
27 = Side Title + Side Text
28 = Side Title + Sidetext + Chart
29 = Title + Content + Content
30 = Title + Content + Small content + Small Content
31 = Title + Small Content + small Content + Content

Thanks

Michael
 
S

Steve Rindsberg

Kathy Jacobs said:
You know... One of us should mark this down and send it Mr. Rindsberg so
that it gets FAQed... Awe - heck - I am just going to email it to him and
hope he sees it.

Ah, so that's what the email was about. Gotcha.

The constant values are all available in the object browser in VBA though.
I'd think most programmers would know that.
 
K

Kathy Jacobs

Yeah - that was what the email was about. And then I had a bad allergic
reaction to some candy second half of last week and never got back to you to
explain. You might think that most programmers would know that, but I
didn't. Then again, whether I am still a programmer or not is best left as a
question for the future to decide. :)
--
Kathy Jacobs, Microsoft MVP OneNote and PowerPoint
Author of Kathy Jacobs on PowerPoint
Get PowerPoint and OneNote information at www.onppt.com

I believe life is meant to be lived. But:
if we live without making a difference, it makes no difference that we lived
 
S

Steve Rindsberg

Kathy Jacobs said:
Yeah - that was what the email was about. And then I had a bad allergic
reaction to some candy second half of last week and never got back to you to
explain. You might think that most programmers would know that, but I
didn't. Then again, whether I am still a programmer or not is best left as a
question for the future to decide. :)

Whatever you are, you're one of em what knows to use the object browser now
though. <g>
 

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