Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
POWERPOINT IN EXCEL | Excel Programming | |||
powerpoint into excel | Excel Programming | |||
Excel and Powerpoint | Excel Programming | |||
Excel and Powerpoint | Excel Discussion (Misc queries) | |||
Powerpoint and Excel | Excel Programming |