Hello!
I am looking for macros or code that can be used to change the
settings of multiple power point files stored on a server (in a
specific folder) and merge them into a single large file. We are
developing a tool, which among other things also has to integrate all
presentations made by our department in a calendar year. The
powerpoint files must be changed to display six slides per page (to
cut down on the number of pages of the final file) irrespective of
whether they were saved in that format or not.
In addition they must be merged into a single file with some basic
data input into the header of each page, along with the logo of the
department... for e.g. '2005 Presentations' and a small image for the
logo.
We are currently using Microsoft technologies for building this tool.
If you want any clarifications, please let me know. Thanks in advance.
TVR-Ga |
Request for Question Clarification by
endo-ga
on
07 Apr 2006 11:28 PDT
Hi,
This can probably be done easily with a VBA macro.
If you give me full details/requirements, I can have a go at it.
For instance, the names of the files, their locations, the headers,
the location of the image, etc.
Thanks.
endo
|
Clarification of Question by
tvr-ga
on
10 Apr 2006 21:23 PDT
Hello endo-ga:
I just checked and came to know that I cannot give out the powerpoint
files and the logo of our organization. I guess, you can still go
ahead with a logo of your choice. If you're using Windows OS, I belive
that you get 4 or 5 different images as a sample in 'Sample Pictures'
under MY Documents--My Pictures. Please use any one of them as the
logo.
For the text, please use: PQR Research Presentations of 2005
Also, try to use about three different powerpoint files each of which
has at least 15 slides.
If you can put up the merged sample online someplace, it would be
great. For the purpose of this macros, you may create a folder called
'PQR Presentations 2005' on your C drive for the source materials and
output the merged files into another folder called 'PQR
Presentations'.
Hope this helps.
TVR-Ga
|
Request for Question Clarification by
maniac-ga
on
11 Apr 2006 18:57 PDT
Hello Tvr,
Merging several files (as you describe in the clarification) is a
straight forward process that a macro can be handle. A few further
questions:
- Is the order of the files important (or can I assume alphabetical
order) in the single large file?
- Are the source / target directories fixed or do you want to specify
where to get the files / put the output?
- What do you mean by "changed to display six slides per page"?
Powerpoint already has an option to print "Handouts (6 slides per
page)". Do you really want six slides merged to be on a single page?
If so, should the merged page have slides from more than one orginal
file (or should the original files appear on separate pages)?
- Do the files have a common master format? If not, do the files need
"massaging" to fit into the master format (and can you describe what
needs to be done)?
- Are the areas on the slides that get the logo / data input already
empty or must something be removed / replaced to add the logo / data
input?
--Maniac
|
Clarification of Question by
tvr-ga
on
12 Apr 2006 11:27 PDT
Hello Manian-ga:
Thanks for your interest.
1. I guess we can get the files named in a sequence. Assume that the
files will be in the following format: 2005-dep1-01, 2005-dep1-02,
2005-dep1-03... 2005-dep2-01, 2005-dep2-02, 2005-dep2-03.. etc. So
they have to be ordered in the sequence of their naming.
2. At some point, we would like to have the flexibility to enter our
own source and target directories, as they may change later.
3. Yes, Powerpoint already has an option to print 6 slides per page.
However, I have noticed that this option works only when you want to
either print the file or to see a print preview, but I did not see an
option to actually save a file in that format (6 slides per page). In
the final output, we want this format of 6 slides per page. So, all
the individual powerpoint presentations must be saved as 6 slides per
page into this final/output file (after merging). E.g. if there are 5
different powerpoint presentations in the source directory each with
30 slides (total: 5x30=150 slides) the merged output should show these
150 slides in the 6 slides per page format i.e. in 25 pages.
However, do keep in mind that each of the 5 original presentations,
must begin on a new page in the final outputted file. So, in the above
example if the first source file had only 26 slides instead of 30,
when the files are being merged, the first slide of the second source
file should still begin on a new page.
4. Files may have a different master format, as they would have been
generated by different individuals and on different days with
different headings, which may have been included into the 'master
slide'.
For the final output (after merging the individual powerpoint files
into one), the following information should appear on each page: Logo
and Text. Please use the following for incorporating the logo and
text.
If you're using Windows OS, I believe that you get 4 or 5 different
images as a sample in 'Sample Pictures' under MY Documents--My
Pictures. Please use any one of them as the logo.
For the text, please use: PQR Research Presentations of 2005
5. We need not change anything on the actual slide, as we want to
retain the same slides that were actually used by our team-members
during their presentations over the year. So, if there is some company
logo on each of the 30 slides of the source powerpoint files, they can
and must remain as they are, even when they are converted into the 6
slides per page format and merged with others. We just need to add the
above logo and text on each of the pages.
Hope this helps. Do feel free to contact me if you have any questions.
Thanks, in advance.
TVR-Ga
|
Request for Question Clarification by
maniac-ga
on
13 Apr 2006 18:36 PDT
Hello Tvr,
Thanks for the clarification. What you describe appears to be pretty
complete at this point.
I am providing this message to give you some brief status.
I did a sample macro recording of the steps to convert six slides into
a single one. Basically the steps:
- create a blank presentation
- open the old presentation (read only)
[start loop six times]
- select next slide in old presentation
- create a "bounding rectangle" in the old slide (that helps align
the copies in the new slide)
- select all objects, group them, and then copy
- select slide in new presentation
- paste special (as a picture)
- resize the picture at 40% (adjustable...)
- relocate the picture
[end loop]
- save the new presentation
This works pretty good manually but the recorded macro was missing
several steps. In looking at the help files / documentation in visual
basic, it appears that not all the operations (e.g., paste special as
a picture) are implemented in VB in Powerpoint
I am currently looking at work arounds to recover from this
deficiency. I should be able to give you an update tomorrow and if one
exists, should have a complete solution on Monday.
--Maniac
|
Request for Question Clarification by
maniac-ga
on
14 Apr 2006 19:01 PDT
Hello Tvr,
I found out through some searches with phrases like
powerpoint paste special limitation
that older versions of PowerPoint does not support several commands
from Visual Basic (including paste special). See
http://support.microsoft.com/kb/222721/EN-US/
for the knowledge base article describing this limitation (and a work
around using MS Word). However, it was added in PowerPoint 2002 as
described at
http://msdn.microsoft.com/library/en-us/vbapp10/html/ppmthPasteSpecial.asp
I will proceed assuming the workaround is needed, but please let me
know which version of PowerPoint you have. Even if you have a newer
version, I'll probably code it up both ways (one active, the other
commented out) in case you have to use an older system.
--Maniac
|
Clarification of Question by
tvr-ga
on
14 Apr 2006 21:11 PDT
Hello Maniac:
We have different versions of powerpoint beginning from 2000 onwards.
So, ideally we would want the code to work for all these types of
files, as you can understand.
Hope this helps.
Best Regards,
TVR-ga
|
Request for Question Clarification by
maniac-ga
on
17 Apr 2006 20:02 PDT
Hello Tvr,
I have a partial solution I would like you to try out. That way, I can
get some feedback on the solution and adjust it.
The macro provided creates an empty presentation (portrait
orientation) and saves it as "SixUp.PPT". It reads "Original.PPT"
(read only) and copies / reformats the first six slides into the SixUp
presentation. I've tested it on a few presentations and it appears to
work OK but I should note a few behaviors:
- it does NOT copy the slide background (nor any information from the
slide master). If this is important, I will need to do some research
to determine if it can be copied.
- it adds a bounding rectangle (white area / black background) to
each slide. That matches the behavior of "six up" in Powerpoint
printing. Another alternative is to capture the background
characteristics and apply it to the bounding rectangle. Do you have a
preference?
To add the macro to one of your presentation, please follow the steps
listed below. Note the steps may vary slightly with Powerpoint
version. Let me know if some step doesn't work.
[1] Open a presentation (or create a blank one)
[2] Using the menu Tools -> Macro -> Visual Basic Editor
[3] I suggest at this point adding a new module (in case you already
have modules in your presentation) to the presentation. There should
be a "project window" in the upper left, make sure your presentation
is selected and then use the menu Insert -> Module. A window should
appear with a title named something like "Presentation1 - Module1
(code)".
[4] Copy & paste the macro from the end of this request into that window.
[5] Check the filenames near the top of the file / make any changes
needed for the test.
[6] You should be able to "Close and Return to Microsoft Powerpoint"
(file menu) to return to the presentation.
[7] At this point, you should be able to use the menu Tools -> Macro
-> Macros to get a list of macros to run. Select SixUp and then Run.
The macro should run for a few seconds and stop. At this point, you
should have the following windows open:
- MS Word - an empty document
- MS Powerpoint - the presentation w/ the macro, the Original.PPT
presentation (marked read only), the SixUp.PPT presentation with the
first six slides pasted in
I suggest running the macro with a few files (rename in the macro or
just copy as "Original.PPT" and let me know if it works as you expect
it to. Between runs, I suggest closing the word document,
Original.PPT, and SixUp.PPT to reduce the possibility of error
messages.
Let me know how it works (and what should be changed) and I'll
incorporate the fixes before doing the rest of the code (multiple
files, handling variable numbers of slides) to submit for an answer.
--Maniac
Note on the code below - it SHOULD copy / paste without error. If GA
wraps one or more lines, the error message(s) should make it obvious
which lines to recombine.
Sub SixUp()
'
' Macro created on 4/13/2006 by Maniac
' Convert a group of slides to "six up" format in a new presentation
'
' Set up for a work around for old Powerpoint versions
' (which don't implement Paste Special)
' Use MS Word to paste special and copy back into Powerpoint
Dim aDoc As Word.Document
Set myDoc = Word.Documents.Add()
' Set up the locations and size for the slides on the new pages
Dim posLeft(5), posTop(5)
posLeft(0) = 0.5 * 72
posTop(0) = 1 * 72
posLeft(1) = 4 * 72
posTop(1) = 1 * 72
posLeft(2) = 0.5 * 72
posTop(2) = 4 * 72
posLeft(3) = 4 * 72
posTop(3) = 4 * 72
posLeft(4) = 0.5 * 72
posTop(4) = 7 * 72
posLeft(5) = 4 * 72
posTop(5) = 7 * 72
eachWidth = 3 * 72
eachHeight = 2 * 72
' Create a new empty (well - one slide) and save it
Set newPres = Presentations.Add(True)
newPres.Slides.Add 1, ppLayoutBlank
newPres.PageSetup.SlideOrientation = msoOrientationVertical
newPres.SaveAs "SixUp.PPT"
' Open the original presentation
' Note - we won't save it with the modifications...
Set oldPres = Presentations.Open( _
"Original.PPT", _
True)
' Set up the values of the bounding rectangle
BRLeft = 0 * 72
BRTop = 0 * 72
BRWidth = 11 * 72
BRHeight = 7.5 * 72
newSlide = 1 ' will go up by one each loop
oldSlide = 0 ' will go up by six each loop
' Inner loop processes six slides on a page
For I = 0 To 5
' Add a bounding rectangle to the original slide
oldPres.Windows(1).Activate
Set BR = oldPres.Slides(oldSlide + I + 1).Shapes.AddShape( _
msoShapeRectangle, _
BRLeft, BRTop, BRWidth, BRHeight)
BR.Fill.ForeColor.RGB = RGB(255, 255, 255)
BR.Line.ForeColor.RGB = RGB(0, 0, 0)
BR.ZOrder msoSendToBack
' Grab all the objects on the original slide (plus the one we added)
numShapes = oldPres.Slides(oldSlide + I + 1).Shapes.Count
Set oldObj = oldPres.Slides(oldSlide + I + 1).Shapes.Range
oldObj.Copy
' Convert copy on clipboard to a picture
myDoc.Windows(1).Activate
Word.ActiveWindow.Selection.PasteSpecial Link:=False, _
DataType:=wdPasteMetafilePicture, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
myDoc.Shapes(1).Select
Word.Selection.Copy
Word.Selection.Delete
' Paste into new location
newPres.Windows(1).Activate
Set curObj = newPres.Slides(newSlide).Shapes.Paste
curObj.Left = posLeft(I)
curObj.Top = posTop(I)
curObj.Width = eachWidth
curObj.Height = eachHeight
Next I
End Sub
|
Request for Question Clarification by
maniac-ga
on
18 Apr 2006 08:29 PDT
Hello Tvr,
After doing a few more tests on another system, I found a couple other
things that you may need to do to get the macro to work properly.
At step 4 (copy / paste), also do the following step:
using menu Tools -> References...
you will get a window listing a possibly HUGE list of object
libraries. You need to scroll down / select one named something like
"Microsoft Word 9.0 Object Library"
(the version may be different on your system)
select OK to confirm that selection. That allows the macro to refer to
Microsoft Word and the tools within it.
Depending on your system set up, MS Word SHOULD run automatically when
you run the macro. If you get an "run time error" and if you select
debug, the error is on the line indicating
Set myDoc = Word.Documents.Add()
then start Word manually before running the macro. The macro is set up
so it won't affect any other documents you have open when it runs.
--Maniac
|
Clarification of Question by
tvr-ga
on
19 Apr 2006 19:48 PDT
Hello Maniac:
I have not come to the Google answers site in the past few days. Now
that I have taken a look at your suggestion, I'll review it in a
couple of days and get back to you. However, this seems to be a macro
that has to be installed into each powerpoint presentation, but this
is just not feasible for us.. .as our objective is to combine tens of
presentations into a single file (for each dept in our organization)
and obviously we cannot manually open each presentation and insert the
macros.... We were expecting some code or macros that we could use in
our software. Are you simultaneously working towards this also? Please
clarify.
Thanks,
TVR-ga
|
Request for Question Clarification by
maniac-ga
on
23 Apr 2006 18:18 PDT
Hello Tvr,
To clarify, the macro can be in a single file (not any of the ones
being merged). That is how I did the testing on my system. The final
version should be able to process several files (e.g., all in a
directory) without any problem as well.
--Maniac
|
Request for Question Clarification by
maniac-ga
on
26 Apr 2006 18:35 PDT
Hello Tvr,
Have you tested what I already sent you (at least for general layout,
problems running it, etc.)?
I have a complete version with the following changes:
- does all files in a directory (settable in the macro)
- uses a "master" file to handle the logo / text on each page (a
slide in themaster file can also serve as a "cover page")
- can ignore some files if needed (e.g., the "master" file, macro
file, other files you specify)
- in each file processed, copies the background color to the 6 up
images (can be adjusted if needed)
If there are no problems, I will gladly post this version as the
answer. If you have had a problem, let me know and I can fix it before
posting the answer.
--Maniac
|