Hi Everyone,
Can you help me? I have this code below and I want to have an auto-loop without specifying my ranges.
Right now, I need to repeat STEP 3 to STEP 8 and change MyRange to "C42:Z77", "C118:Z153"
****
Sub Excel_to_Powerpoint()
'Step 1: Declare your variables
Dim pp As Object
Dim PPPres As Object
Dim PPSlide As Object
Dim xlwksht As Worksheet
Dim MyRange As String
Dim MyTitle As String
'Step 2: Open PowerPoint, add a new presentation and make visible
Set pp = CreateObject("PowerPoint.Application")
Set PPPres = pp.Presentations.Add
pp.Visible = True
'Step 3: Set the ranges for your data and title
MyRange = "C4:Z39" '<<<Change this range
'Step 4: Start the loop through each worksheet
Worksheets("CHS_PowerPoint").Select
Application.Wait (Now + TimeValue("0:00:1"))
'Step 5: Copy the range as picture
Worksheets("CHS_PowerPoint").Range(MyRange).CopyPicture _
Appearance:=xlScreen, Format:=xlPicture
'Step 6: Count slides and add new blank slide as next available slide number
'(the number 12 represents the enumeration for a Blank Slide)
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, 12)
PPSlide.Select
'Step 7: Paste the picture and adjust its position
PPSlide.Shapes.Paste.Select
pp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
pp.ActiveWindow.Selection.ShapeRange.Top = 0
pp.ActiveWindow.Selection.ShapeRange.Left = 0
pp.ActiveWindow.Selection.ShapeRange.Height = 480
pp.ActiveWindow.Selection.ShapeRange.Width = 720
'Step 8: Add the title to the slide then move to next worksheet
'Step 9: Memory Cleanup
pp.Activate
Set PPSlide = Nothing
Set PPPres = Nothing
Set pp = Nothing
End Sub
Can you help me? I have this code below and I want to have an auto-loop without specifying my ranges.
Right now, I need to repeat STEP 3 to STEP 8 and change MyRange to "C42:Z77", "C118:Z153"
****
Sub Excel_to_Powerpoint()
'Step 1: Declare your variables
Dim pp As Object
Dim PPPres As Object
Dim PPSlide As Object
Dim xlwksht As Worksheet
Dim MyRange As String
Dim MyTitle As String
'Step 2: Open PowerPoint, add a new presentation and make visible
Set pp = CreateObject("PowerPoint.Application")
Set PPPres = pp.Presentations.Add
pp.Visible = True
'Step 3: Set the ranges for your data and title
MyRange = "C4:Z39" '<<<Change this range
'Step 4: Start the loop through each worksheet
Worksheets("CHS_PowerPoint").Select
Application.Wait (Now + TimeValue("0:00:1"))
'Step 5: Copy the range as picture
Worksheets("CHS_PowerPoint").Range(MyRange).CopyPicture _
Appearance:=xlScreen, Format:=xlPicture
'Step 6: Count slides and add new blank slide as next available slide number
'(the number 12 represents the enumeration for a Blank Slide)
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, 12)
PPSlide.Select
'Step 7: Paste the picture and adjust its position
PPSlide.Shapes.Paste.Select
pp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
pp.ActiveWindow.Selection.ShapeRange.Top = 0
pp.ActiveWindow.Selection.ShapeRange.Left = 0
pp.ActiveWindow.Selection.ShapeRange.Height = 480
pp.ActiveWindow.Selection.ShapeRange.Width = 720
'Step 8: Add the title to the slide then move to next worksheet
'Step 9: Memory Cleanup
pp.Activate
Set PPSlide = Nothing
Set PPPres = Nothing
Set pp = Nothing
End Sub