Create Multiple PowerPoint Slides

J

Jim

I am using PowerPoint 2003.

I have a HTML/ASP web page that uses DIV and TABLE statements to create data
for a PowerPoint slide.

My code works if I create a single slide. I have not figured out how to make
multiple slides.

If I try to create multiple slides, all the data overwrites slide number
one. What I need is something like the page break used in Word.

This is a small example to illustrate the problem:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<%Dim ndx%>
<head>
<title>Test Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="pragma" CONTENT="nocache">
<style>
<!--
BODY { position:absolute; font:Times New Roman; font-size:12pt;
font-weight:bold; line-height:0.75 }
-->
</style>
</head>
<body>
<% for ndx = 1 to 2 %>
<div align="center" style="top:18px; height:20px;
font-size:14pt">UNCLAS</div>
<div align="center" style="top:42px; height:20px; font-size:18pt">ISSUE
<%=ndx%> TITLE GOES HERE</div>
<% next %>
</body>
</html>
<%
'set page content type, etc.
Response.ContentType = "application/vnd.ms-powerpoint"
Response.addheader "Content-Disposition", "attachment; filename=PPSample.ppt"
%>


In this example, two slides should be created, each with a different number
in the ndx field of the title of the second DIV statement. My problem is that
only one is created and the ndx field is overwritten.

I am trying to eliminate using Office Automation with PowerPoint running on
our server.


Thanks in advance for any and all help.
 
S

Steve Rindsberg

I am using PowerPoint 2003.

I have a HTML/ASP web page that uses DIV and TABLE statements to create data
for a PowerPoint slide.

My code works if I create a single slide. I have not figured out how to make
multiple slides.

There's no notion of a page break in PowerPoint

You'll have to:

- write multiple HTML files, one per slide

- work out how to write MHT files

- create files in the new office XML format (but recipients would need either
PPT 2007 or an earlier version with the compatibility pack installed to open
them)
 
J

Jim

I have not worked with MHT files before. The only direct interface with
PowerPoint is through the Response.ContentType =
"application/vnd.ms-powerpoint" statement.

How would I create the MHT and XML files using the example code?
 
S

Steve Rindsberg

I have not worked with MHT files before. The only direct interface with
PowerPoint is through the Response.ContentType =
"application/vnd.ms-powerpoint" statement.

How would I create the MHT and XML files using the example code?

That's far too big a subject for a newsgroup post, I'm afraid, and I have far
too little knowledge to explain it properly anyhow.

But both formats are fairly well documented.

This WikiPedia article has links to MHTML references:
http://en.wikipedia.org/wiki/MHTML

Google "open xml" for information on Office 2007's XML format.
 
J

Jim

Thanks for the reply. I will check out the link.

As a alternative, is it posible to change Office Automation for PowerPoint
that is running on the server so that it runs on the clients machine?

The code to generate PowerPoint slides is called from a web page, generated
on the server, then the link to the file is passed back to the users web
page. Below is an example of the code I am currently using to create the
slides. If this can be changed to do all the work on the clients machine then
that would solve my problem. All clients will have the current version of
PowerPoint loaded.

<%
Dim ndx 'Loop index
Dim oFSO 'File system object
Dim oPPT 'Powerpoint object
Dim oPres 'Presentation object
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test Document<</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="pragma" CONTENT="nocache">
</head>

<body>
<%
'Create file system object
set oFSO = Server.CreateObject("Scripting.FileSystemObject")
'Create the Powerpoint Object
Set oPPT = Server.CreateObject("PowerPoint.Application")
Set oPres = oPPT.Presentations.Add
'Save file to server
oPres.SaveAs Server.MapPath("/") & "\toolset\muteable\temp\" &
"TestDocument.ppt"

'Generate as many slides as required
for ndx = 1 to 3
'Generate slide
GenerateSlide
next

set oPres = nothing
oPPT.quit
set oPPT = nothing
set oFSO = nothing

sub GenerateRapidsSlide()
With oPres
'Create new slide (number 1) using the blank layout
.Slides.Add ndx, 12 '12 = ppLayoutBlank
AddHeaderInfo
'Add textbox for the Background label
textbox.Slides(ndx).Shapes.AddTextbox 1, 4,
((.Slides(ndx).Shapes(.Slides(ndx).Shapes.Count).Top) + _
(.Slides(ndx).Shapes(.Slides(ndx).Shapes.Count).Height)), 716, 22
With .Slides(ndx).Shapes(.Slides(ndx).Shapes.Count).TextFrame.TextRange
.Text = "BACKGROUND:"
.ParagraphFormat.Bullet = False
.Characters.Font.Name = "Times New Roman"
.Characters.Font.Size = 12
.Characters.Font.Bold = True
.Characters.Font.Underline = True
End With
End With
'Save the generated slide
oPres.Save
end sub

sub AddHeaderInfo()
With oPres
'Add textbox (shape 1) field
.Slides(ndx).Shapes.AddTextbox 1, 0, 0, 720, 17
'Set font size for the field
With .Slides(ndx).Shapes(1).TextFrame.TextRange
.Text = "Header Info Field"
.ParagraphFormat.Bullet = False
.ParagraphFormat.Alignment = 1 'AlignLeft
.Characters.Font.Name = "Times New Roman"
.Characters.Font.Size = 14
.Characters.Font.Bold = True
End With
End With
end sub
%>
</body>
</html>

If this is better suited for another discussion group please let me know.

Thanks for any and all help.
 
S

Steve Rindsberg

Thanks for the reply. I will check out the link.

As a alternative, is it posible to change Office Automation for PowerPoint
that is running on the server so that it runs on the clients machine?

That'd depend (among other things) on how much control you have over the
client's machine; can you ensure that it has an addin installed or that you're
able to run an executable?

If so, the client machine should be able to do the job. There'd have to be some
mechanism to pass the client any necessary data; a client PPT add-in can
automatically run code every time PPT starts. It could e.g. use FTP or HTTP to
bring down a data file from the server and then act on it.

And by the way, I can't think of a better place than this to post this
discussion. No problem there.
 
J

Jim

Getting the data from the server will not be a problem. I just need to know
what changes are required to be made in the sample code below to get
PowerPoint to start/run on the clients machine.
 
S

Steve Rindsberg

Getting the data from the server will not be a problem. I just need to know
what changes are required to be made in the sample code below to get
PowerPoint to start/run on the clients machine.

Ok, that makes sense. For starters, to get code to run on PPT startup, you'll
need to put it in an add-in and install that on the client machine.

Alternatively, you could write a small script/vb/other EXE to watch a directory
and launch PPT, then automate it as needed.

Have a look here (you'll probably have to fix linebreaks)
Creating and Installing Add-ins, Toolbars, Buttons
http://www.pptfaq.com/index.html#name_Creating_and_Installing_Add-ins-_Toolbars
-_Buttons

As to the code:

You'll want to dim your variables as specific types, so:

Dim ndx as Long
Dim oFSO 'File system object
' I don't use FSO; you'll have to work out how to dim that
' Dim oPPT ... don't need this
Dim oPres as Presentation

'Create file system object
' guessing here:
set oFSO = CreateObject("Scripting.FileSystemObject")

' Not needed since we're IN ppt now
' 'Create the Powerpoint Object
' Set oPPT = Server.CreateObject("PowerPoint.Application")

Set oPres = oPPT.Presentations.Add

' save as path will have to be modified for the client machine
'Save file to server
oPres.SaveAs Server.MapPath("/") & "\toolset\muteable\temp\" &
"TestDocument.ppt"

'Generate as many slides as required
for ndx = 1 to 3
'Generate slide
' Shouldn't this be GenerateRapidsSlide?
' If so, change its sig to GeneratedRapidsSlide(oPres as Presentation)
' then call GenerateRapidsSlide(oPres)
GenerateSlide
next

oPres.Close

set oPres = nothing
' oPPT.quit
' set oPPT = nothing
set oFSO = nothing

sub GenerateRapidsSlide()
With oPres
'Create new slide (number 1) using the blank layout
.Slides.Add ndx, 12 '12 = ppLayoutBlank
AddHeaderInfo
'Add textbox for the Background label
textbox.Slides(ndx).Shapes.AddTextbox 1, 4,
((.Slides(ndx).Shapes(.Slides(ndx).Shapes.Count).Top) + _
(.Slides(ndx).Shapes(.Slides(ndx).Shapes.Count).Height)), 716, 22
With .Slides(ndx).Shapes(.Slides(ndx).Shapes.Count).TextFrame.TextRange
.Text = "BACKGROUND:"
.ParagraphFormat.Bullet = False
.Characters.Font.Name = "Times New Roman"
.Characters.Font.Size = 12
.Characters.Font.Bold = True
.Characters.Font.Underline = True
End With
End With
'Save the generated slide
oPres.Save
end sub

sub AddHeaderInfo()
With oPres
'Add textbox (shape 1) field
.Slides(ndx).Shapes.AddTextbox 1, 0, 0, 720, 17
'Set font size for the field
With .Slides(ndx).Shapes(1).TextFrame.TextRange
.Text = "Header Info Field"
.ParagraphFormat.Bullet = False
.ParagraphFormat.Alignment = 1 'AlignLeft
.Characters.Font.Name = "Times New Roman"
.Characters.Font.Size = 14
.Characters.Font.Bold = True
End With
End With
end sub
 
J

Jim

The sample code is a HTML/ASP/VBScript web page that is called to build the
slides. ASP web pages run on the server and does not allow for identifying
the specific types on DIM statements. Also, I am not trying "... to get code
to run on PPT startup ...". I am trying to get PPT to start, on the client
machine, from my web page code which is running on the server (because it is
ASP/VBScript code).

The code changes you identified would be correct for VBA or PPT macros.

I may be trying to do something that PowerPoint was not designed to do.

I will keep trying to inplement your previous suggestion of using MHT and
XML files.
 
S

Steve Rindsberg

The sample code is a HTML/ASP/VBScript web page that is called to build the
slides. ASP web pages run on the server and does not allow for identifying
the specific types on DIM statements. Also, I am not trying "... to get code
to run on PPT startup ...". I am trying to get PPT to start, on the client
machine, from my web page code which is running on the server (because it is
ASP/VBScript code).

My misunderstanding ... thought you wanted to modify the code so it RAN on the
client machine. Yep, this'd be quite different.

DCOM might be capable of this but I've no idea how you'd go about it.
 

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

Similar Threads


Top