I am new to VBA and wondering if some one can help me. I have written Vba codes which creates power point slides by taking data and charts from the excel . i am using excel 2010 and power point 2010.
The code is working ok, the issue i am facing is the pictures are not pasted in the middle of the slides. All the shapes are pasted on the top left hand corner.
Below is my codes any help will be appreciated. i have tried different methods but i am definitely missing very important point. Also one more thing, some time when i run the code, not both of them get updated but when i refresh again two or three times it gets updated.
Sub creatpp()
Dim myppt As PowerPoint.Application
Set myppt = New PowerPoint.Application
myppt.Visible = msoCTrueActiveSheet.Shapes.Range(Array("Object 4")).Select Selection.Verb Verb:=xlOpen
Dim mypres As PowerPoint.Presentation
Set mypres = myppt.ActivePresentation
Dim mySlide1 As PowerPoint.Slide
Dim mySlide4 As PowerPoint.Slide
Set mySlide1 = mypres.Slides(1)
Set mySlide4 = mypres.Slides(4)
Dim wb As WorkbookSet wb = ActiveWorkbookwb.Activate
wb.Sheets("Slides").Visible = xlSheetVisible
wb.Sheets("Slides").Range("A12:G20").Copy
' Slide 1 Copy and paste next range
myppt.Activate
On Error Resume Next
For Each Shape In mySlide1.Shapes
If Shape.Type = msoPicture Then
Shape.Delete
End If
Next
mySlide1.Shapes.PasteSpecial ppPasteMetafilePicture
'With PPPres.Slides(1)
'.Shapes.Paste
'With myslides1.Shapes(Shapes.Count)
'.LockAspectRatio = msoTrue
'.Left = 25
'.Top = 100
'.Height = 300
'End With
'Slide 4 Copy and paste next range
wb.Sheets("Slides").Range("A112:F118").Copy
myppt.Activate
On Error Resume Next
For Each Shape In mySlide4.Shapes
If Shape.Type = msoPicture Then
Shape.Delete
End If
Next
mySlide4.Shapes.PasteSpecial ppPasteMetafilePicture
Application.ErrorCheckingOptions.NumberAsText = False
wb.Sheets("Slides").Visible = xlSheetVeryHidden
End Sub<strike></strike>
The code is working ok, the issue i am facing is the pictures are not pasted in the middle of the slides. All the shapes are pasted on the top left hand corner.
Below is my codes any help will be appreciated. i have tried different methods but i am definitely missing very important point. Also one more thing, some time when i run the code, not both of them get updated but when i refresh again two or three times it gets updated.
Sub creatpp()
Dim myppt As PowerPoint.Application
Set myppt = New PowerPoint.Application
myppt.Visible = msoCTrueActiveSheet.Shapes.Range(Array("Object 4")).Select Selection.Verb Verb:=xlOpen
Dim mypres As PowerPoint.Presentation
Set mypres = myppt.ActivePresentation
Dim mySlide1 As PowerPoint.Slide
Dim mySlide4 As PowerPoint.Slide
Set mySlide1 = mypres.Slides(1)
Set mySlide4 = mypres.Slides(4)
Dim wb As WorkbookSet wb = ActiveWorkbookwb.Activate
wb.Sheets("Slides").Visible = xlSheetVisible
wb.Sheets("Slides").Range("A12:G20").Copy
' Slide 1 Copy and paste next range
myppt.Activate
On Error Resume Next
For Each Shape In mySlide1.Shapes
If Shape.Type = msoPicture Then
Shape.Delete
End If
Next
mySlide1.Shapes.PasteSpecial ppPasteMetafilePicture
'With PPPres.Slides(1)
'.Shapes.Paste
'With myslides1.Shapes(Shapes.Count)
'.LockAspectRatio = msoTrue
'.Left = 25
'.Top = 100
'.Height = 300
'End With
'Slide 4 Copy and paste next range
wb.Sheets("Slides").Range("A112:F118").Copy
myppt.Activate
On Error Resume Next
For Each Shape In mySlide4.Shapes
If Shape.Type = msoPicture Then
Shape.Delete
End If
Next
mySlide4.Shapes.PasteSpecial ppPasteMetafilePicture
Application.ErrorCheckingOptions.NumberAsText = False
wb.Sheets("Slides").Visible = xlSheetVeryHidden
End Sub<strike></strike>