junkew Posted 4 hours ago Posted 4 hours ago What do you mean with "strip whitespace from PNG's" dealing with a lot of images can cause memory leaks. In 3.3.16 maybe check if your index is sometimes 132. That you don't see weird behavior is not the same as beeing correct. Change the approach First count png images Then insert count slides Then iterate all slides to set the notes page Instead of add slide, settext,add slide set text, ... FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
prutser Posted 4 hours ago Author Posted 4 hours ago (edited) 53 minutes ago, junkew said: What do you mean with "strip whitespace from PNG's" dealing with a lot of images can cause memory leaks. In 3.3.16 maybe check if your index is sometimes 132. That you don't see weird behavior is not the same as being correct. Change the approach First count png images Then insert count slides Then iterate all slides to set the notes page Instead of add slide, settext,add slide set text, ... With the knowledge of today, my approach should be quite different, make use of arrays and follow the path you described. The "strip whitespace". For worships in our Sunday services we download songs from a paid database. They are always 1280x800 resolution, but with different sized borders around the song . In order to have them as big as possible on the beamer my script scans all 4 sides where the first "non-white" pixel is found, cuts the whitespace, magnifies it to 1280 horizontal or 800 vertical, what comes first, and a new picture is created from that and imported in a slide. In the notespage soms items are mentioned about the song (number, verse, etcetera). Interesting part maybe is that if I skip the notespage code and only use the calls in the UDF from Water, it still fails in 3.3.18. Not always. If I run 10X the same item, only 1 or 2 runs fail. The approach in the code is now to do that picture for picture, where it is more efficient to do it batchwise. Normally it are 30-40 slides per presentation. I took all reactions with me and changed already a lot of stuff. The PPT UDF is the one from Water and I found yesterday also the webpages about the placeholders and notespage, I included there also a check on being an object and the right type of variable, but the issues stays in 3.3.18 version where 3.3.16.1 works flawless. The other hand, a test script creating a PPT slideshow, writing 100.000 times a notespage AND putting text and a picture on a slide works also 100% fine in 3.3.18. So there must be something in my code resulting in an error in 3.3.18 where the older Autoit version gives the expected result. Best approach is to leave the old code and start from scratch with a better version which handles all stuff batchwise. I started the first part of my code in 2013 and the stuff added is certainly not state of the art. I think that putting effort in a new version with up-to-date UDF's, better naming convention, proper use of functions makes more sense than finding the needle in the haystack. But still a hurdle to take ... The past days I learned a lot from the PPT UDF from Water - what a clean and nice looking code! - and all reactions, very thankful for that. I know what my next step must be, I know ... Edited 3 hours ago by prutser Clearification
prutser Posted 1 hour ago Author Posted 1 hour ago (edited) On 1/9/2026 at 11:22 PM, mLipok said: oh I see it is here: @prutser try this: Func _PPT_SlideNotesTextFrameSetText(ByRef $obj_pres, $amount, $obj_slide, $Text) If IsObj($obj_pres) <> 1 Then SetError(1) Return 0 Else $ShapeCount = _PPT_SlideShapeCount($obj_pres, $amount) _Debugprint("Shapes: " & $Shapecount & ". SlideNote op dia " & $amount & " " & $Text) Local $oSlides = $obj_pres.Slides($amount) If @error Then Return SetError(@error, @extended, 0) Local $oNotesPage = $oSlides.NotesPage If @error Then Return SetError(@error, @extended, 0) Local $oShape2 = $oNotesPage.Shapes(2) If @error Then Return SetError(@error, @extended, 0) Local $oTextFrame = $oShape2.TextFrame If @error Then Return SetError(@error, @extended, 0) Local Local $oTextRange = $oTextFrame.TextRange If @error Then Return SetError(@error, @extended, 0) $oTextRange.Text = $Text If @error Then Return SetError(@error, @extended, 0) Endif EndFunc Sorry it took some time, I tried several things. Due to the change to the UDF of Water, some things are changed in the code. A check is done on more items (see below), if a failure occurs, it has something to do with the itemnumer of the Slides property Used this code to make a testscript that creates a slideshow, adds a slide and fills the slidenumber into the speakernote. Running that 10 times with 100 slides per run ... Flawless with expected result. Last time one slide overwritten 100.000 times, excellent in both AutoIt 3.3.16.1 and 3.3.18. And that with the old AND the new code (see below) So I tend to believe that the code is ok. Func _PPT_SlideNotesTextFrameSetText(ByRef $oObj, $iSlide, $sText = "") If Not IsObj($oObj) Or ObjName($oObj, 1) <> "_Presentation" Then Return SetError(1, 0, 0) ;Check on validity op object and type If VarGetType($oObj.Slides($iSlide).Notespage.Shapes(2)) <> "Object" Or $oObj.Slides($iSlide).Notespage.Shapes(2).HasTextFrame = 0 Or $sText = "" Then Return SetError(1, 0, 0) ;Check Object, textframe and text $oObj.Slides($iSlide).Notespage.Shapes(2).TextFrame.TextRange.Text = $sText ;Fill speaker notes EndFunc ;==>_PPT_SlideNotesTextFrameSetText Code and COM error: expandcollapse popupFunc _PPT_SlideNotesTextFrameSetText(ByRef $oObj, $iSlide, $sText = "") If Not IsObj($oObj) Or ObjName($oObj, 1) <> "_Presentation" Then Return SetError(1, 0, 0) ;Check on validity op object and type If VarGetType($oObj.Slides($iSlide).Notespage.Shapes(2)) <> "Object" Or $oObj.Slides($iSlide).Notespage.Shapes(2).HasTextFrame = 0 Or $sText = "" Then Return SetError(1, 0, 0) ;Check Object, textframe and text Local $oSlides = $oObj.Slides($iSlide) If @error Then Return SetError(@error, @extended, 0) Local $oNotesPage = $oSlides.NotesPage If @error Then Return SetError(@error, @extended, 0) Local $oShape2 = $oNotesPage.Shapes(2) If @error Then Return SetError(@error, @extended, 0) Local $oTextFrame = $oShape2.TextFrame If @error Then Return SetError(@error, @extended, 0) Local $oTextRange = $oTextFrame.TextRange If @error Then Return SetError(@error, @extended, 0) $oTextRange.Text = $sText If @error Then Return SetError(@error, @extended, 0) $oObj.Slides($iSlide).Notespage.Shapes(2).TextFrame.TextRange.Text = $sText ;Fill speaker notes EndFunc ;==>_PPT_SlideNotesTextFrameSetText COM Error Encountered in PPTtool 3.72.au3 UDF version = PowerPoint: 1.5.0.0 2021-08-31 @AutoItVersion = 3.3.18.0 @AutoItX64 = 0 @Compiled = 0 @OSArch = X64 @OSVersion = WIN_11 Scriptline = 4445 NumberHex = 0x80020008 Number = -2147352568 WinDescription = Ongeldig type variabele. Description = Source = HelpFile = HelpContext = LastDllError = 0 ======================================================== "R:\PPTtool 3.72.au3" (4445) : ==> Variable must be of type "Object".: $oObj.Slides($iSlide).Notespage.Shapes(2).TextFrame.TextRange.Text = $sText $oObj.Slides($iSlide)^ ERROR No errorcode activated, but still an error in the last line just above the Endfunc. What I wrote earlier this evening, the code is not what I like to see nowadays, I will start a new codebranch and spend my time making (far) better code that polishing bad code. But it itches that I cannot lay my finger on this Thanks for your time and efforts! Edited 1 hour ago by prutser
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now