Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default VBA between excel and powerpoint

Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent
  #2   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default VBA between excel and powerpoint

you can start from he http://peltiertech.com/Excel/XL_PPT.html

--
KL
[MVP - Microsoft Excel]
RU: http://www.mvps.ru/Program/Default.aspx
ES: http://mvp.support.microsoft.com/?LN=es-es
EN: http://mvp.support.microsoft.com/?LN=en-us
Profile: https://mvp.support.microsoft.com/pr...A-9E6C73C09A36


"Kent" wrote in message ...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA between excel and powerpoint

Here is a simple example that paste the activechart in

Sub CreatePowerPoint()
Dim oPPApp As Object
Dim oPPPres As Object
Dim oPPSlide As Object

Set oPPApp = CreateObject("Powerpoint.Application")

Set oPPPres = oPPApp.Presentations.Add
oPPApp.Visible = True

oPPApp.ActiveWindow.ViewType = 1 'ppViewSlide

Set oPPSlide = oPPPres.Slides.Add(1, 11) 'ppLayoutTitleOnly

ActiveChart.CopyPicture Appearance:=xlScreen, _
Size:=xlScreen, _
Format:=xlPicture

oPPSlide.Shapes.Paste.Select

oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default VBA between excel and powerpoint

Kent

Here's the theory. It uses early binding, so you will need to set a
reference to the PowerPoint library through ToolsReferences.. in the Excel
VBE. I used a diagram 2 on sheet1 in Excel

Sub AutomatePowerPoint()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim xlDiagram As Shape

Set ppApp = New PowerPoint.Application
Set ppPres = ppApp.Presentations.Add
Set ppSlide = ppPres.Slides.Add(1, ppLayoutBlank)
Set xlDiagram = Worksheets("Sheet1").Shapes("Diagram 2")

ppApp.Visible = msoTrue

xlDiagram.Copy

ppSlide.Shapes.Paste

Set xlDiagram = Nothing
Set ppSlide = Nothing
Set ppPres = Nothing
Set ppApp = Nothing
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA between excel and powerpoint

msoTrue instead of True. Interesting ....

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Nick Hodge" wrote in message
...
Kent

Here's the theory. It uses early binding, so you will need to set a
reference to the PowerPoint library through ToolsReferences.. in the
Excel VBE. I used a diagram 2 on sheet1 in Excel

Sub AutomatePowerPoint()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim xlDiagram As Shape

Set ppApp = New PowerPoint.Application
Set ppPres = ppApp.Presentations.Add
Set ppSlide = ppPres.Slides.Add(1, ppLayoutBlank)
Set xlDiagram = Worksheets("Sheet1").Shapes("Diagram 2")

ppApp.Visible = msoTrue

xlDiagram.Copy

ppSlide.Shapes.Paste

Set xlDiagram = Nothing
Set ppSlide = Nothing
Set ppPres = Nothing
Set ppApp = Nothing
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram
and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default VBA between excel and powerpoint

Bob

I thought it strange too, but I know so little about the PP object model I
went with the 'boolean' intellisense gave me!

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Bob Phillips" wrote in message
...
msoTrue instead of True. Interesting ....

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Nick Hodge" wrote in message
...
Kent

Here's the theory. It uses early binding, so you will need to set a
reference to the PowerPoint library through ToolsReferences.. in the
Excel VBE. I used a diagram 2 on sheet1 in Excel

Sub AutomatePowerPoint()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim xlDiagram As Shape

Set ppApp = New PowerPoint.Application
Set ppPres = ppApp.Presentations.Add
Set ppSlide = ppPres.Slides.Add(1, ppLayoutBlank)
Set xlDiagram = Worksheets("Sheet1").Shapes("Diagram 2")

ppApp.Visible = msoTrue

xlDiagram.Copy

ppSlide.Shapes.Paste

Set xlDiagram = Nothing
Set ppSlide = Nothing
Set ppPres = Nothing
Set ppApp = Nothing
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram
and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default VBA between excel and powerpoint

This worked - Thanks a lot..

I can not get the "Dim as a Powerpoint.Application to work, but the Object
dose.

"Bob Phillips" wrote:

Here is a simple example that paste the activechart in

Sub CreatePowerPoint()
Dim oPPApp As Object
Dim oPPPres As Object
Dim oPPSlide As Object

Set oPPApp = CreateObject("Powerpoint.Application")

Set oPPPres = oPPApp.Presentations.Add
oPPApp.Visible = True

oPPApp.ActiveWindow.ViewType = 1 'ppViewSlide

Set oPPSlide = oPPPres.Slides.Add(1, 11) 'ppLayoutTitleOnly

ActiveChart.CopyPicture Appearance:=xlScreen, _
Size:=xlScreen, _
Format:=xlPicture

oPPSlide.Shapes.Paste.Select

oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default VBA between excel and powerpoint

Kind of makes you wonder at what point in time
TRUE < msoTrue
will become True (or msoTrue, depending?)
If nothing else, it serves as a reminder that you're working within the mso
library rather than the application's?

But I digress, and offer nothing additional for the OP, so I shall leave
now...

"Nick Hodge" wrote:

Bob

I thought it strange too, but I know so little about the PP object model I
went with the 'boolean' intellisense gave me!

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Bob Phillips" wrote in message
...
msoTrue instead of True. Interesting ....

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Nick Hodge" wrote in message
...
Kent

Here's the theory. It uses early binding, so you will need to set a
reference to the PowerPoint library through ToolsReferences.. in the
Excel VBE. I used a diagram 2 on sheet1 in Excel

Sub AutomatePowerPoint()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim xlDiagram As Shape

Set ppApp = New PowerPoint.Application
Set ppPres = ppApp.Presentations.Add
Set ppSlide = ppPres.Slides.Add(1, ppLayoutBlank)
Set xlDiagram = Worksheets("Sheet1").Shapes("Diagram 2")

ppApp.Visible = msoTrue

xlDiagram.Copy

ppSlide.Shapes.Paste

Set xlDiagram = Nothing
Set ppSlide = Nothing
Set ppPres = Nothing
Set ppApp = Nothing
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram
and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default VBA between excel and powerpoint

Kent

As I outlined, mine uses early binding so you have to add the reference
manually in advance. I prefer early binding as it speeds my coding because
I get intellisense. Also as I start with managed code it is stronger typed
and good current practice.

However as Bob's code worked...that's all that matters

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Kent" wrote in message
...
This worked - Thanks a lot..

I can not get the "Dim as a Powerpoint.Application to work, but the Object
dose.

"Bob Phillips" wrote:

Here is a simple example that paste the activechart in

Sub CreatePowerPoint()
Dim oPPApp As Object
Dim oPPPres As Object
Dim oPPSlide As Object

Set oPPApp = CreateObject("Powerpoint.Application")

Set oPPPres = oPPApp.Presentations.Add
oPPApp.Visible = True

oPPApp.ActiveWindow.ViewType = 1 'ppViewSlide

Set oPPSlide = oPPPres.Slides.Add(1, 11) 'ppLayoutTitleOnly

ActiveChart.CopyPicture Appearance:=xlScreen, _
Size:=xlScreen, _
Format:=xlPicture

oPPSlide.Shapes.Paste.Select

oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram
and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA between excel and powerpoint

Kent,

To use Nick's code, you have to go into ToolsReferences in the VBIDE, and
check the Microsoft PowerPoint library item.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Kent" wrote in message
...
This worked - Thanks a lot..

I can not get the "Dim as a Powerpoint.Application to work, but the Object
dose.

"Bob Phillips" wrote:

Here is a simple example that paste the activechart in

Sub CreatePowerPoint()
Dim oPPApp As Object
Dim oPPPres As Object
Dim oPPSlide As Object

Set oPPApp = CreateObject("Powerpoint.Application")

Set oPPPres = oPPApp.Presentations.Add
oPPApp.Visible = True

oPPApp.ActiveWindow.ViewType = 1 'ppViewSlide

Set oPPSlide = oPPPres.Slides.Add(1, 11) 'ppLayoutTitleOnly

ActiveChart.CopyPicture Appearance:=xlScreen, _
Size:=xlScreen, _
Format:=xlPicture

oPPSlide.Shapes.Paste.Select

oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Kent" wrote in message
...
Hi - I need some help.

I'm new to VBA.

My problem is that I in Excel need to make a picture copy of a diagram
and
then post it in a new slide in a open powerpoint presentation.

But how do i write code in a Excel makro to work in Powerpoint?

Br Kent








  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBA between excel and powerpoint

Hi,
I used your routine and it works very well.
I made a change: I don't paste a chart but a range ex: A1:AZ90 but I
have a problem.
It pastes not the whole selection range but only a little part of it.

How can I paste the whole selection?

Thanks a lots

Denis



Bob Phillips ha scritto:

Here is a simple example that paste the activechart in

Sub CreatePowerPoint()
Dim oPPApp As Object
Dim oPPPres As Object
Dim oPPSlide As Object

Set oPPApp = CreateObject("Powerpoint.Application")

Set oPPPres = oPPApp.Presentations.Add
oPPApp.Visible = True

oPPApp.ActiveWindow.ViewType = 1 'ppViewSlide

Set oPPSlide = oPPPres.Slides.Add(1, 11) 'ppLayoutTitleOnly

ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

oPPSlide.Shapes.Paste.Select

oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
oPPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
POWERPOINT IN EXCEL Kari J Keinonen[_2_] Excel Programming 0 January 16th 07 12:13 AM
powerpoint into excel Peter[_55_] Excel Programming 4 November 24th 05 04:18 PM
Excel and Powerpoint funkymonkUK[_14_] Excel Programming 2 May 27th 05 09:51 PM
Excel and Powerpoint freekrill Excel Discussion (Misc queries) 0 November 26th 04 01:50 AM
Powerpoint and Excel Vish Excel Programming 0 April 23rd 04 12:06 AM


All times are GMT +1. The time now is 12:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"