Jump to content

Recommended Posts

Posted (edited)

Hi all,

I have code running to strip whitespace from PNG's and put them into a PowerPoint slideshow. Until last week I used AutoIT version 3.3.16.1 with several UDF's. Last week I upgraded to 3.3.18.0 and there is something weird now. My code runs approx. 80% of the time flawless, but sometimes there is an error related to PowerPoint. Reverting back to 3.3.16.1 looks to solve the issue. Alle used UDF's are in a separate location and the same for both versions of AutoIT.  The error is at random places in the code, but always in a line doing something with a PowerPoint slide.

The given error is always:

==> Variable must be of type "Object".:

An example of code where the error appears in 10-20% of the cases:

image.thumb.png.77d6595392d950aeb552e349060d89e1.png

And the error (at random places and 10-20% of the cases:

image.png.b83944e4e8dbd3e2fc9f9ba2f2842aa0.png

 

What is weird in my opinion:

  • The PPT used is always started in the beginning of the code and 100% of the time visible, so sure it's there
  • The error show up at random places, but always with a connection to a PowerPoint object, but not consistent every time. Running the same code with the same PNG input repetitive gives 80% consistent expected results, 20% error messages on different places
  • I seems only to happen with 3.3.18.0. I reverted back a few times from 3.3.16.1 to 3.3.18.0 and back (default installation, only change is that I choose "Edit" for the doubleclick action on a AU3 file). Running the code in 3.3.16.1 10 times gives never (knocks on wood) an error, in 3.3.18.0 in 1-2 cases out of 10. I did repeat this sequence a few times with the same results
  • The "object" error is strange because the line in front (see code) uses the same object ...

The PPT UDF is in both cases exactly the same, the Powerpoint.au3 from Toady. PowerPoint stays the same (Office 2021) en the PC used is a standard W11 Pro thing. I'm back on 3.3.16.1 right now that I used the past years.

Anyway, I'm back on 3.3.16.1, but there is something strange. No hassle for me at the moment, but it looks to me there is a something changed under the hood ...

Many thanks for the community for all efforts that helped me in the last 10 years!

 

Edited by prutser
Typo's
Posted
8 minutes ago, prutser said:

Anyway, I'm back on 3.3.16.1, but there is something strange.

As you posted, all we all can say is "oh wow". To troubleshoot code, the code should be available as text, not a picture of a chunk.
I don't even have PowerPoint installed not ever used, so not much help from me.
If you present a simple short script that shows the trouble that can be replicated, then there is going to be a better chance to attend to it.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
8 minutes ago, argumentum said:

As you posted, all we all can say is "oh wow". To troubleshoot code, the code should be available as text, not a picture of a chunk.
I don't even have PowerPoint installed not ever used, so not much help from me.
If you present a simple short script that shows the trouble that can be replicated, then there is going to be a better chance to attend to it.

Thanks for your reply. I'm 100% sure it is not the code. And yes, I know that everybody will tell that, that's why I described extensively why I came to that conclusion. I have tested the code today approx. 50 times with 3.3.16.1 without a single failure, where 3.3.18.0 fails 9 time from another 50 times. All 100 times the used input and environment were 100% the same. The given error is not logical because the lines before the error the same object is used. My post is more intended for the AutoIT devs that something had changed in 3.3.18.0 leading to the errors.

Posted

When I'm working with COM objects I ALWAYS install a COM error handler and check @error and @extended after each function call of an UDF.
Toady's PPT UDF does not use a COM error handler.
Often some function causes the problem in first place. If unhandled, your script will crash on another line. This is very hard to debug.
I suggest to add a COM error handler to your script to get better debugging information about the line that really causes the problem.
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Or download my PPT UDF (for download please see my signature), grab function _PPT_ErrorNotify, add it to your script and call _PPT_ErrorNotify(1) at the op of your script.
You will get all COM errors written to the console.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted
On 1/7/2026 at 5:51 PM, water said:

Or download my PPT UDF (for download please see my signature), grab function _PPT_ErrorNotify, add it to your script and call _PPT_ErrorNotify(1) at the op of your script.
You will get all COM errors written to the console.

Great, that will be done for the next few minutes. I tried to make a look-alike script that automated runs a few 100 sheets and that 500 times, but that works fine in both versions and is not giving a clue. Will try also on another PC if that makes a difference. It should be a lot nicer if the error was more consistent, I understand that this is a needle in a haystack without some evidence that produces the error.

Thanks for your time and effort in this, greatly appreciated!

Posted

The COM error routine is the best invention just after wheels. Extremely helpful, it gives direction, however in this case not 100% clarity. Errors are still random. Below the output from one error message (1st code) and the code involved (2nd screenshot)

-->Line(0241):  Shapes: 4. SlideNote op dia 6 Picture_001 1280x800

COM Error Encountered in PPTtool 3.71.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 = 242
NumberHex = 0x80020008
Number = -2147352568
WinDescription = Ongeldig type variabele.
Description = 
Source = 
HelpFile = 
HelpContext = 
LastDllError = 0
========================================================
"\Include\PowerPoint.au3" (242) : ==> Variable must be of type "Object".:
$obj_pres.Slides($amount).NotesPage.Shapes(2).TextFrame.TextRange.Text = $Text
$obj_pres.Slides($amount)^ ERROR
->22:55:16 AutoIt3.exe ended.rc:1
+>22:55:16 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 28.72

What you see above is the output of the "Debugprint" on line 0241 in the code below. That line proves that the $obj_pres object exists. The amount of shapes on the page is visually checked and really "4" (the picture, the notespage, a block and an arrow). In other words, Shape(2) is writeable. Also, the variables "$amount" and "$Text" have values (respectively "6" and "Picture_001 1280x800". The intention of the code is to fill the notesfield in PowerPoint with the filename and resolution of the picture

One line later tells now that the object from the previous line is gone. If I change nothing and run the code again, it runs 2-5 times flawless before giving an error on this or another place. If the error happens, it is always in a part of the code where several "object" commands are executed in a few lines. Until now it never crashed in a piece of code where only one "object" command is executed. 

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)
        $obj_pres.Slides($amount).NotesPage.Shapes(2).TextFrame.TextRange.Text = $Text
    Endif
EndFunc


Func _PPT_SlideShapeCount($obj, $intSlide)
    If IsObj($obj) <> 1 Then
        SetError(1)
        Return 0
    Else
        Return $obj.Slides.Item($intSlide).Shapes.Range.Count
    Endif
EndFunc

My guess for now: The error has a connection with multiple consecutive actions on objects (not necessarily PowerPoint), but unfortunately not very consistent.

Some text is in Dutch in the codeparts, but you get the drift I think ...

Next step is to look if I can minimize the amount of object actions and a way to copy this into a small piece of code running on an active PPT window, but that's for the weekend. And repeat this on another PC.

Thanks again, I learned so much this evening. Priceless!

Posted (edited)

  

42 minutes ago, prutser said:
"\Include\PowerPoint.au3" (242) : ==> Variable must be of type "Object".:
$obj_pres.Slides($amount).NotesPage.Shapes(2).TextFrame.TextRange.Text = $Text
$obj_pres.Slides($amount)^ ERROR

 

Which version of PowerPoint UDF are you using?

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted (edited)

Hi mLipok,

An old one from Toady. I only use a few functions from there like opening a PPT, create slide, slidecount. No fancy things in there and only simple functions in use with object-oneliners like mentioned below. Compared it already several times with the mentioned newer UDF, but in fact the same objecthandling.

But because I only use some simple stuff, I will change to the newer UDF this weekend, that does not hurt :)

Func _PPT_PresentationOpen($obj, $filepath, $ReadOnly=True, $Title=True, $Visible=True)
    If IsObj($obj) <> 1 Then
        SetError(1)
        Return 0
    Else
        Local $PresInterface = $obj.Presentations
        Local $objPres = $PresInterface.Open($filepath,$ReadOnly,$Title,$Visible)
        Return $objPres
    Endif
EndFunc

Func _PPT_SlideCreate($obj, $index, $layout, $backgroundcolor = 0xFFFFFF)
    Local Const $ppBackground = 1
    If IsObj($obj) <> 1 Then
        SetError(1)
        Return 0
    Else
        Local $SlideClass = $obj.Slides.Add($index, $layout)
        $SlideClass.Colorscheme.Colors($ppBackground).RGB = $backgroundcolor
        Return $SlideClass
    Endif
EndFunc
9 hours ago, mLipok said:

Which version of PowerPoint UDF are you using?

 

Edited by prutser
Saved some space
Posted
9 hours ago, mLipok said:

Which version of PowerPoint UDF are you using?

This has already been answered in post #1 by the OP 😉 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted
9 hours ago, prutser said:
WinDescription = Ongeldig type variabele.

lets me think that some type of data is invalid.
Can you please insert the following lines ahead of the failing statement in line #242?

Consolewrite("Value of $amount: '" & $amount & "', Variable Type of $amount: " & VargetType($amount) & @CRLF)
Consolewrite("Value of $Text: '" & $Text & "', Variable Type of $Text: " & VargetType($Text) & @CRLF)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

BTW:
I suggest to use the proposed naming convention as described here. So you always know which type of data to expect from a variable :) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...