VBA powerpoint creation

S

simon cory

I am new to VBA and powerpoint. I have a commercial application that has
VBA imbedded in it and I need to create a VBA script that takes some
information from the commercial application and puts it in to a new slide in
a new powerpoint presentation.

Could somebody give some pointers as to how I might do this or where I might
go to get more information?

Thanks in advance for your help,
 
B

Bill Dilworth

This depends completely on the application and how it was coded, so it is
difficult to advise you without knowing more.

The only advise I would feel comfortable with is to a) monkey around with it
and hope it doesn't break or 2) write to the author and ask.

Some info that would be helpful...

What application?
Who made it?
What info/type of object?
What version of PowerPoint?

--
Bill Dilworth
Microsoft PPT MVP Team
Users helping fellow users.
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of your questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
S

simon cory

http://www.tripos.com/sciTech/inSilicoDisc/dataAnalysis/lithium.html#base

The above is the application I'm using. It has a very rich object model to
describe molecules. It allows visualiztion of molecules, with captions etc.
It contains the Microsoft VBA Integrated Development Environment (IDE) to
allow for scripting.

My simple task is to take a current view (I can copy the image ok in VBA),
then open up PowerPoint, add a slide, add the image of the moelcule, then
add any captions that are present.

I am a complete novice in VBA (and powerpoint) and just wanted some pointers
to where I should start learning how to do this. I have some programming
knowledge in C++ and some other scripting languages, but was not sure how to
write a script in VBA in order to manipulate a new PowerPoint view.

Thanks

SC
 
S

Shyam Pillai

Simon,
The following code will generate a PPT using the image that is copied to
this clipboard. You should be able to paste this into the app with VBA
support and get it running.
'---------------------------------------------------------
Option Explicit
Private Sub GenPPT()
Dim oPPTApp As Object 'PowerPoint.Application
Dim oPPTPres As Object 'PowerPoint.Presentation
Dim oPPTSlide As Object 'PowerPoint.Slide
Dim oPPTShp As Object 'PowerPoint.Shape

Set oPPTApp = CreateObject("PowerPoint.Application")
If Not oPPTApp Is Nothing Then
With oPPTApp
.Visible = True
Set oPPTPres = .Presentations.Add(False)
If Not oPPTPres Is Nothing Then
Set oPPTSlide = oPPTPres.Slides.Add(1, 1)
With oPPTSlide
' Assuming that the image is already available in the clipboard
On Error Resume Next
Set oPPTShp = .Shapes.Paste(1)
If Not oPPTShp Is Nothing Then
Call CenterShape(oPPTShp, oPPTPres)
Else
MsgBox "Failure to paste shape.", vbCritical, _
"PowerPoint Automation Example"
End If
With .Shapes.AddTextbox(1, 0, 0, _
oPPTPres.PageSetup.SlideWidth, _
oPPTPres.PageSetup.SlideHeight)
.TextFrame.TextRange.Text = "Enter captions here"
.TextFrame.TextRange.ParagraphFormat.Alignment = 2
' Postion caption shape as desired
'
'
End With
End With
oPPTPres.NewWindow
Else
MsgBox "Failure to create new presentation." & _
vbCritical + vbOKOnly, "PowerPoint Automation Example"
End If
End With
Else
MsgBox "Failure to instantiate PowerPoint session.", _
vbCritical + vbOKOnly, "PowerPoint Automation Example"
End If
End Sub

Sub CenterShape(oShp As Object, oPres As Object)
With oShp
.Left = (oPres.PageSetup.SlideWidth - .Width) / 2
.Top = (oPres.PageSetup.SlideHeight - .Height) / 2
End With
End Sub
'---------------------------------------------------------
 
S

simon cory

Thank you - that works great - it gives me a great starting place for
playing around and experimenting.

Could you recommend any useful web sites that will help in this learning
process?

Thanks again

SC
 
R

Rich

Hello Shyam It's time to (finally) write your book on VBA! We'll even PAY
for it! Rich
 
D

David M. Marcovitz

Hello Shyam It's time to (finally) write your book on VBA! We'll
even PAY for it! Rich

As the author of the only book about VBA in PowerPoint, I second that
motion. My book is fine for beginners, but many people need more than what
my book offers. In fact, I need more than what my book offers. I figure my
book covers about 1% of what Shyam knows about PowerPoint and VBA, so we're
all waiting for Shyam's book so we can learn the other 99%.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
R

Rich

David (et al) I have this book (Powerpoint for Educators) It should have
been sold at the last PPTLive conference in San Diego. David, you will be
there this year right?? The book has been very helpful in putting together
some very good presentations. But...we are still waiting for Shyam to 'share
the wealth'
Rich
 

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