Pavan.Sada.PS
Member
Dear Friends,
Below is the code which updates data form the excel 2007 file to the chosen sample ppt file. One of my colleague have created this code and he is not there in the organization. this code will work fine if we use MS office 2007. However if we use this code in 2010 MS office it is not working. Any help in amending the code would really be helpful to me in completing my project.
I am not able to update the said excel file and ppt file due to its confidentiality. But let me know if u need the file I will remove confidential info from that file and upload it.
Below is the code which updates data form the excel 2007 file to the chosen sample ppt file. One of my colleague have created this code and he is not there in the organization. this code will work fine if we use MS office 2007. However if we use this code in 2010 MS office it is not working. Any help in amending the code would really be helpful to me in completing my project.
Code:
Sub PPT_Create()
On Error GoTo X
File_Name = ThisWorkbook.FullName
New_PPT = MsgBox("Do you want to create a new PPT?", vbYesNo)
If New_PPT = 6 Then
S_Count = 1
Set New_PowerPoint = Nothing
If New_PowerPoint Is Nothing Then
Set New_PowerPoint = CreateObject("PowerPoint.Application")
New_PowerPoint.Visible = True
ActiveWindow.Visible = True
ActiveWindow.Activate
ActiveWorkbook.Activate
New_PowerPoint.WindowState = 2
File_Name = Application.GetOpenFilename("Microsoft PowerPoint-Files (*.ppt), *.ppt")
If File_Name = "False" Then End
New_PowerPoint.Presentations.Open Filename:=File_Name
While New_PowerPoint.ActivePresentation.Slides.Count > 0
New_PowerPoint.ActivePresentation.Slides(S_Count).Delete
Wend
End If
AppActivate New_PowerPoint.Name
New_PowerPoint.ActivePresentation.Slides.Add New_PowerPoint.ActivePresentation.Slides.Count + 1, 12
New_PowerPoint.ActiveWindow.View.GotoSlide New_PowerPoint.ActivePresentation.Slides.Count
Set Active_Slide = New_PowerPoint.ActivePresentation.Slides(New_PowerPoint.ActivePresentation.Slides.Count)
ActiveWorkbook.ActiveSheet.Range("C3:I6").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Active_Slide.Shapes.Paste.Select
Active_Slide.Shapes(Active_Slide.Shapes.Count).LockAspectRatio = False
Active_Slide.Shapes(Active_Slide.Shapes.Count).Width = 650
Active_Slide.Shapes(Active_Slide.Shapes.Count).Left = 28
Active_Slide.Shapes(Active_Slide.Shapes.Count).Top = 50
ActiveWorkbook.ActiveSheet.Range("B" & ActiveWorkbook.Names("Solid_First_Row").RefersToRange - 4 & ":M" & ActiveWorkbook.Names("Stretch_Last_Row").RefersToRange + 1).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Active_Slide.Shapes.Paste.Select
Active_Slide.Shapes(Active_Slide.Shapes.Count).LockAspectRatio = False
Active_Slide.Shapes(Active_Slide.Shapes.Count).Left = 28
Active_Slide.Shapes(Active_Slide.Shapes.Count).Top = 120
Active_Slide.Shapes(Active_Slide.Shapes.Count).Height = 380
Active_Slide.Shapes(Active_Slide.Shapes.Count).Width = 650
Application.CutCopyMode = False
ActiveWorkbook.Activate
New_PowerPoint.WindowState = 2
Else
S_Count = 1
If New_PowerPoint Is Nothing Then End
New_PowerPoint.ActiveWindow.View.GotoSlide New_PowerPoint.ActivePresentation.Slides.Count
New_PowerPoint.ActivePresentation.Slides.Add New_PowerPoint.ActivePresentation.Slides.Count + 1, 12
New_PowerPoint.ActiveWindow.View.GotoSlide New_PowerPoint.ActivePresentation.Slides.Count
Set Active_Slide = New_PowerPoint.ActivePresentation.Slides(New_PowerPoint.ActivePresentation.Slides.Count)
ActiveWorkbook.ActiveSheet.Range("C3:I6").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Active_Slide.Shapes.Paste.Select
Active_Slide.Shapes(Active_Slide.Shapes.Count).LockAspectRatio = False
Active_Slide.Shapes(Active_Slide.Shapes.Count).Width = 650
Active_Slide.Shapes(Active_Slide.Shapes.Count).Left = 28
Active_Slide.Shapes(Active_Slide.Shapes.Count).Top = 50
ActiveWorkbook.ActiveSheet.Range("B" & ActiveWorkbook.Names("Solid_First_Row").RefersToRange - 4 & ":M" & ActiveWorkbook.Names("Stretch_Last_Row").RefersToRange + 1).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Active_Slide.Shapes.Paste.Select
Active_Slide.Shapes(Active_Slide.Shapes.Count).LockAspectRatio = False
Active_Slide.Shapes(Active_Slide.Shapes.Count).Left = 28
Active_Slide.Shapes(Active_Slide.Shapes.Count).Top = 120
Active_Slide.Shapes(Active_Slide.Shapes.Count).Height = 380
Active_Slide.Shapes(Active_Slide.Shapes.Count).Width = 650
Application.CutCopyMode = False
End If
X:
ActiveSheet.Range("$A$1").Select
End Sub
I am not able to update the said excel file and ppt file due to its confidentiality. But let me know if u need the file I will remove confidential info from that file and upload it.