praveenlal
New Member
- Joined
- Oct 27, 2021
- Messages
- 34
- Office Version
- 2016
- Platform
- Windows
Hi All,
I've written this code but getting Compile Error = Next without For error. Any expert help please
Sub Create_PPT()
Dim ppt_app As New PowerPoint.Application
Dim pre As PowerPoint.Presentation
Dim slde As PowerPoint.slide
Dim shp As PowerPoint.shape
Dim wb As Workbook
Dim rng As range
Dim vSheet$
Dim vRange$
Dim vWidth As Double
Dim vHeight As Double
Dim vTop As Double
Dim vLeft As Double
Dim vSlide_No As Long
Dim expRng As range
Dim adminSh As Worksheet
Dim configRng As range
Dim xlfile$
Dim pptfile$
Application.DisplayAlerts = False
Set adminSh = ThisWorkbook.Sheets("Data")
Set configRng = adminSh.range("rng_sheet")
xlfile = adminSh.[excelPth]
pptfile = adminSh.[pptPath]
Set wb = Workbooks.Open(xlfile)
Set pre = ppt_app.Presentations.Open(pptfile)
Set excelPth = adminSh.[excelPth]
Set pptPath = adminSh.[pptPath]
Set expRng = Sheets(vSheet$).range(vRange$)
Set slde = pre.Slides(vSlide_No)
Set shp = slde.Shapes(1)
wb.Activate
For Each rng In configRng
With ThisWorkbook.Sheets("Data")
wb.Sheets(rng.Value).Activate
With adminSh
vSheet$ = .Cells(rng.Row, 4).Value
vRange$ = .Cells(rng.Row, 5).Value
vWidth = .Cells(rng.Row, 6).Value
vHeight = .Cells(rng.Row, 7).Value
vTop = .Cells(rng.Row, 8).Value
vLeft = .Cells(rng.Row, 9).Value
vSlide_No = .Cells(rng.Row, 10).Value
End With
wb.Activate
Sheets(vSheet$).Activate
expRng.Copy
slde.Shapes.PasteSpecial ppPasteBitmap
With shp
.Top = vTop
.Left = vLeft
.Width = vWidth
.Height = vHeight
End With
Set shp = Nothing
Set slde = Nothing
Application.CutCopyMode = False
Next rng ''''GETTING ERROR ON THIS LINE''''
pre.Save
Set pre = Nothing
Set ppt_app = Nothing
Set expRng = Nothing
wb.Close False
Set wb = Nothing
Application.DisplayAlerts = True
End Sub
I've written this code but getting Compile Error = Next without For error. Any expert help please
Sub Create_PPT()
Dim ppt_app As New PowerPoint.Application
Dim pre As PowerPoint.Presentation
Dim slde As PowerPoint.slide
Dim shp As PowerPoint.shape
Dim wb As Workbook
Dim rng As range
Dim vSheet$
Dim vRange$
Dim vWidth As Double
Dim vHeight As Double
Dim vTop As Double
Dim vLeft As Double
Dim vSlide_No As Long
Dim expRng As range
Dim adminSh As Worksheet
Dim configRng As range
Dim xlfile$
Dim pptfile$
Application.DisplayAlerts = False
Set adminSh = ThisWorkbook.Sheets("Data")
Set configRng = adminSh.range("rng_sheet")
xlfile = adminSh.[excelPth]
pptfile = adminSh.[pptPath]
Set wb = Workbooks.Open(xlfile)
Set pre = ppt_app.Presentations.Open(pptfile)
Set excelPth = adminSh.[excelPth]
Set pptPath = adminSh.[pptPath]
Set expRng = Sheets(vSheet$).range(vRange$)
Set slde = pre.Slides(vSlide_No)
Set shp = slde.Shapes(1)
wb.Activate
For Each rng In configRng
With ThisWorkbook.Sheets("Data")
wb.Sheets(rng.Value).Activate
With adminSh
vSheet$ = .Cells(rng.Row, 4).Value
vRange$ = .Cells(rng.Row, 5).Value
vWidth = .Cells(rng.Row, 6).Value
vHeight = .Cells(rng.Row, 7).Value
vTop = .Cells(rng.Row, 8).Value
vLeft = .Cells(rng.Row, 9).Value
vSlide_No = .Cells(rng.Row, 10).Value
End With
wb.Activate
Sheets(vSheet$).Activate
expRng.Copy
slde.Shapes.PasteSpecial ppPasteBitmap
With shp
.Top = vTop
.Left = vLeft
.Width = vWidth
.Height = vHeight
End With
Set shp = Nothing
Set slde = Nothing
Application.CutCopyMode = False
Next rng ''''GETTING ERROR ON THIS LINE''''
pre.Save
Set pre = Nothing
Set ppt_app = Nothing
Set expRng = Nothing
wb.Close False
Set wb = Nothing
Application.DisplayAlerts = True
End Sub