View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
God Itself God Itself is offline
external usenet poster
 
Posts: 29
Default [VBA] loop, problem of 101'st iteration

hello,

i wrote such a code:

Sub All_creation()
Application.ScreenUpdating = False
Dim VBCodeMod As CodeModule
Dim StartLine As Long
Dim HowManyLines As Long
Dim PPObj As Object

Set PPObj = CreateObject("PowerPoint.application")

Sheets("ID").Cells(43, 11).Value = 3

a = Range("M50").Value

For i = 1 To a 'a = 140 (LICZBA ITERACJI)

Sheets("ID").Cells(50, 11).Value = i

Range("L50").Formula = "=LEFT(INDEX(etykiety!R4C7:R300C7,RC[-1],1),5)"
Range("M50").Formula =
"=ROWS(etykiety!R4C7:R300C7)-COUNTBLANK(etykiety!R4C7:R300C7)"
Range("N50").Formula =
"=IF(R50C12="""","""",INDEX(R3C2:R602C2,MATCH(MID( LEFT(R50C12,4)&""0"",1,5),R3C6:R602C6,0),1))"
Range("O50").Value = "0"
Range("P50").Formula = "=IF(R50C12="""","""",MID(R50C12,5,1))"

Sheets("ID").Cells(3, 8).Value = Sheets("ID").Cells(50, 15).Value
'dopelnienie
Sheets("ID").Cells(3, 13).Value = Sheets("ID").Cells(50, 14).Value 'main
Sheets("ID").Cells(3, 14).Value = Sheets("ID").Cells(50, 16).Value 'klasa

Calculate

'### PRN ###

With PPObj
' .presentations.Add
.presentations.Open Filename:="F:\Analizy ISI\pl\AnBrMan.ppt"
.Visible = True
.Run "AnBrMan.ppt!UpdateMode"
.presentations("AnBrMan.ppt").Save

With PPObj.ActivePresentation.PrintOptions
.PrintInBackground = msoTrue
.RangeType = ppPrintAll
.Collate = msoTrue
.PrintColorType = ppPrintColor
.ActivePrinter = "Adobe PDF"
End With

PPObj.ActivePresentation.PrintOut PrintToFile:="F:\Analizy
ISI\pl\files\F-pdf\K\" & _
Workbooks("panel_et.xls").Sheets("ID").Cells(3, 16).Value & "\" & _
Workbooks("panel_et.xls").Sheets("ID").Cells(3, 15).Value & ".prn"

.presentations("AnBrMan.ppt").Close

End With

Next i

Application.ScreenUpdating = True
End Sub


key parameter in module is 'a' (it is number of iteration in loop)
unfortunately when 'i' equals 101 a module stops with error (error concerns
module in powerpoint document):

..Run "AnBrMan.ppt!UpdateMode"

best regards