View Single Post
  #4   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

Error (during 101 loop) sounds:

Run-time error '-2147467259 (8004005)':

Automation Error
Undefined error ' translation from Polish

and when debug is pressed following part of code (given in first message in
this topic) is marked:

PPObj.ActivePresentation.PrintOut
PrintToFile:="F:\AnalizyISI\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"

regards


Użytkownik "God Itself" napisał w wiadomości
...
Hi,

1. yes, it is always after 100 loops, even i start loop from 1 to 80 and
then second loop from 1 to 50 then i get problem at 21'st in 2nd loop

2. there are no common variables. macro in powerpoint is as follows:

Sub UpdateMode()

Dim lCtrA As Integer
Dim oPres As Object 'Presentation
Dim oSld As Slide
Set oPres = ActivePresentation
With oPres
' Process shapes on the slides
For Each oSld In .Slides
Call UpdtLinks(oSld)
Next
' Process shapes on the slides masters
If Val(Application.Version) 9 Then
'For versions 2002 and later with multiple master support
For lCtrA = 1 To .Designs.Count
If .Designs(lCtrA).HasTitleMaster Then
Call UpdtLinks(.Designs(lCtrA).TitleMaster)
Else
Call UpdtLinks(.Designs(lCtrA).SlideMaster)
End If
Next
Else
' Version 97/2000
Call UpdtLinks(.SlideMaster)
If .HasTitleMaster Then
Call UpdtLinks(.TitleMaster)
End If
End If
End With

End Sub
Sub UpdtLinks(oSlideOrMaster As Object)
Dim oShp As PowerPoint.Shape
For Each oShp In oSlideOrMaster.Shapes
If oShp.Type = msoLinkedOLEObject Then
'update links
oShp.LinkFormat.Update
End If
Next oShp
End Sub

3. any application does not wait for another. but i'm only 99% sure

4. no function returns more than 255 character result. spreadsheet seems
to be ok

i'll paste error msg today evening

regards


Użytkownik "Cringing Dragon"
napisał w wiadomości
...
Have you run this with a set to a smaller number? Does it run, and do
everything that you expect it to? Does it work when a is 99, 100, and
101?
I'm just confirming that it's at exactly a=101 that there is a problem,
and
not just at a figure somewhere near there.

If I read your message (and the macro) right, then a PowerPoint macro
gets
called inside the loop, and that's where the Excel macro is stopping.
Does
the PowerPoint macro use the variable i, or the worksheet range
Sheets("ID").Cells(50, 11), or any other counter that's driven by the
loops?
If it does, then does it do something with that number that might be a
problem when it hits a 3 digit number?

When Excel starts the PowerPoint macro running, does Excel wait for that
to
finish before running the next code line
(.presentations("AnBrMan.ppt").Save)? If not, it could be related to
that -
PowerPoint attempting to save while a PP macro is running. I'm not sure
why
it would wait until loop 101 to complain, though.

If you manually set sheet ID Cell K50 (is that the one that i gets
written
to?) to 101, is everything OK in the spreadsheet?
Does i=101 push any filenames or vba strings over 255 characters? In
Excel
2003, there are still some issues in VBA with long strings, I don't know
about Excel 2007.

You're also printing to a pdf file each loop. There's nothing to make it
pause after sending the print job, so you might be hitting a limitation
on
the print spooler when too many jobs are spooled. But I can't see why
that
would make it stop at the PowerPoint macro line, so I doubt that's the
problem.