Thread: Excel VB Code
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ranjit kurian Ranjit kurian is offline
external usenet poster
 
Posts: 83
Default Excel VB Code

Hi Steve,

when i only copied add textbox code from your macro its not working, same as
the below manner i copied it, actually i want the macro to create a new
textbox, please help me...

Dim myRange As Range
Dim currShapeRange As PowerPoint.ShapeRange
Dim currShape As PowerPoint.Shape
Dim lngSlideHeight As Long
Dim lngSlideWidth As Long

' Add text box with text to Slide 1
Set currShape = PPPres.slides(1).Shapes _
..AddTextbox(msoTextOrientationHorizontal, 20, 20, 500, 500)
With currShape
With .TextFrame.textrange
..Text = "This is just an experiment"
With .ParagraphFormat
..Alignment = ppAlignLeft
..Bullet = msoFalse
End With
With .Font
..Bold = msoTrue
..Name = "Tahoma"
..Size = 24
End With
End With
'' Shrink text box to text it now contains
'width = .TextFrame.textrange.BoundWidth
'height = .TextFrame.textrange.BoundHeight
End With

"Steve Yandl" wrote:

See if this example gives you any ideas.

Steve


Sub UpdatePPTslide()

Dim myRange As Range
Dim ppApp As PowerPoint.Application
Dim prsPres As PowerPoint.Presentation
Dim currShapeRange As PowerPoint.ShapeRange
Dim currShape As PowerPoint.Shape
Dim lngSlideHeight As Long
Dim lngSlideWidth As Long

' Copy range from Sheet2 of active workbook
Set myRange = Sheets(2).UsedRange
myRange.Copy


' Open and reference the presentation, MyShow.ppt
Set ppApp = CreateObject("PowerPoint.Application")
ppApp.Visible = msoTrue
Set prsPres = ppApp.Presentations.Open("C:\Test\MyShow.ppt")
' Get dimensions of a slide
lngSlideHeight = prsPres.PageSetup.SlideHeight
lngSlideWidth = prsPres.PageSetup.SlideWidth

' Delete all shapes on Slide 1 of MyShow.ppt
' Paste Excel range
With prsPres.Slides(1)
If .Shapes.Count 0 Then
.Shapes.Range.Delete
End If
Set currShapeRange = .Shapes.PasteSpecial
End With

' Resize the pasted Excel range
With currShapeRange
.ScaleHeight 1.2, msoFalse
.ScaleWidth 1.1, msoFalse
End With

' Add text box with text to Slide 1
Set currShape = prsPres.Slides(1).Shapes _
.AddTextbox(msoTextOrientationHorizontal, 20, 20, 500, 500)
With currShape
With .TextFrame.TextRange
.Text = "This is just an experiment"
With .ParagraphFormat
.Alignment = ppAlignLeft
.Bullet = msoFalse
End With
With .Font
.Bold = msoTrue
.Name = "Tahoma"
.Size = 24
End With
End With
' Shrink text box to text it now contains
..Width = .TextFrame.TextRange.BoundWidth
..Height = .TextFrame.TextRange.BoundHeight
End With

' Save changes, close presentation and quit PowerPoint
prsPres.Save
prsPres.Close
ppApp.Quit
Set prsPres = Nothing
Set ppApp = Nothing
End Sub


"Ranjit kurian" wrote in message
...
Hi Steve,

Below is my excel macro code which open the powerpoint application of
previous week then delete the existing pictures and copy the new pictures
from excel sheet, till here its working fine for me , but after doing all
these things i need my excel macro to add text box to ppt slide and type a
text given by me.