Sign in to follow this  
Followers 0
DHL

PowerPoint COM event handler initialization error

12 posts in this topic

#1 ·  Posted (edited)

Hi, I'm getting this error while trying to initialize a com event handler for Office PowerPoint events. The PowerPoint file is displayed correctly, but no events are captured as the ObjEvent() fails :

err.number is: -2147316576
err.windescription: Type mismatch.

err.description is:
err.source is:
err.helpfile is:
err.helpcontext is: 0
err.lastdllerror is: 0
err.scriptline is: 23
err.retcode is: 0

The sourcecode is:

Local $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler
Func MyErrFunc($oError)
ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
         "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
         "err.description is: " & @TAB & $oError.description & @CRLF & _
         "err.source is: " & @TAB & $oError.source & @CRLF & _
         "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
         "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
         "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
         "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
         "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc
Local $AppPowerPoint = ObjCreate("PowerPoint.Application")
If Not IsObj($AppPowerPoint) Then
MsgBox(0, "Error", "$AppPowerPoint is not an Object.")
Else
MsgBox(0, "Error", "Successfully created Object $AppPowerPoint.")
EndIf
Local $pptEvt = ObjEvent($AppPowerPoint, "PowerPointEvent_") ; Initialize PowerPoint COM event handlers
Local $OpenPresentation = $AppPowerPoint.Presentations.Open("C:\Users\DagHendrik\Desktop\test.ppt",True, False, False)
$OpenPresentation.SlideShowSettings.ShowPresenterView = 0
$OpenPresentation.SlideShowSettings.ShowType = 1
Local $SlideShowWindow = $OpenPresentation.SlideShowSettings.Run()
While True
Sleep(10)
WEnd

Func PowerPointEvent_SlideShowNextSlide($obj)
ConsoleWrite("GetCurrentSlide = " & ($SlideShowwindow.View.Slide.SlideIndex-1) & "<"& @LF)
EndFunc
Func PowerPointEvent_SlideShowOnNext($obj)
ConsoleWrite("GetCurrentSlide = " & ($SlideShowwindow.View.Slide.SlideIndex-1) & "<"& @LF)
EndFunc

The script continues fine, but no event are fired as the line with

Local $pptEvt = ObjEvent($AppPowerPoint, "PowerPointEvent_") ; Initialize PowerPoint COM event handlers
fails.

I'm using the latest autoit (v3.3.8.1, 32 bit) And I'm running Office PowerPoint 2013 32bit on a Windows 8 Pro 64 bit installation.

Any idea why the ObjEvent() fails?

(EDIT: changed to autoit code formatting)

Edited by DHL

Share this post


Link to post
Share on other sites



But doesn't the error happen on line 23 which is "Local $SlideShowWindow = $OpenPresentation.SlideShowSettings.Run()"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I think some of the formatting got lost when I copy-pasted the code. The error happens on the line

Local $pptEvt = ObjEvent($AppPowerPoint, "PowerPointEvent_") ; Initialize PowerPoint COM event handlers

The application and presentation loads fine, but because the event handler initialization failed I don't get any events back when advance through the slides

Edited by DHL

Share this post


Link to post
Share on other sites

I tried here (AutoIt 3.3.8.1, Windows 7 64 bit, Office 2010 32 bit) and get the same error. But I can't see anything wrong.

I will check again after I had my coffee ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Great :-) Thanks.

Share this post


Link to post
Share on other sites

Seems to be a problem with PowerPoint. As soon as I replace "PowerPoint.Application" with "Outlook.Application" or "Excel.Application" the error is gone.

Needs some more investigation ...


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I tried the code with AutoIT 3.3.6.1 and then it worked fine!

Seems like something has changed for the worse in AutoIt 3.3.8.1. Any idea?

Share this post


Link to post
Share on other sites

Some changes have been made to COM (error handling) since 3.3.6.1.

IIRC the Devs made some notes that COM support was somehow broken before 3.3.8.1. They fixed it and performance dropped a bit and maybe the problem you see has been caused by this changes too.

Could you please download the latest beta version (3.3.9.4) and try again. The latest beta has seen some changes in the COM area again. The beta can be installed in parallel to the production version.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I tried with the latest beta and got the same error:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users\DagHendrik\Desktop\d.au3" /UserParams    
+>16:39:42 Starting AutoIt3Wrapper v.2.1.0.33    Environment(Language:0409  Keyboard:00000414  OS:WIN_8/  CPU:X64 OS:X64)
>Running AU3Check (3.3.9.4)  from:C:\Program Files (x86)\AutoIt3\beta
+>16:39:42 AU3Check ended.rc:0
>Running:(3.3.9.4):C:\Program Files (x86)\AutoIt3\beta\autoit3.exe "C:\Users\DagHendrik\Desktop\d.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
err.number is:  -2147316576
err.windescription: Type mismatch.

err.description is:  
err.source is:  
err.helpfile is:  
err.helpcontext is:  0
err.lastdllerror is:  0
err.scriptline is:  19
err.retcode is:  0

Share this post


Link to post
Share on other sites

Sorry, then I have run out of ideas <_<

You can either open an error ticket on Trac or stay with 3.3.6.1


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for the help anyway, water :-)

I submitted a ticket here: http://www.autoitscript.com/trac/autoit/ticket/2316

Share this post


Link to post
Share on other sites

Let's see what the Devs say ...


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0

  • Similar Content

    • zetaimmersion
      By zetaimmersion
      Hi all. 
      I am trying to do 2 things but i cannot seem to get any traction on how to read/implement this idea.
      Premise: PowerPoint file in C\temp\presentation.pptx that contains on the first slide 2 entries as "<one>" and "<two>" which need to be replaced with "user1" and "user2", then a silent Outlook send mail containing the file with a predefined body and subject.
      I narrowed it down to COM objects as the Office does not like intrusive open AutoIt functions. I installed OLE/COM Object Viewer to understand how to create the commands but i am still stuck. So far i am trying to user water's code but i suck
      COM object i was originally trying to modify
      Dim $oPPT, $oPres $oPPT = ObjCreate("PowerPoint.Application") $oPPT.Visible = True $oPres = $oPPT.Presentations.Read Water's code below (0.1% modified)
      #include <File.au3> #include "PowerPoint.au3" #include <misc.au3> Global $sFile = "C:\temp\presentation.pptx" Global $sString2Search = "<username>", $sString2Replace = "Password", $iReplaceOnce = 1, $sFullLogFile = "C:\temp\pptxlog.txt" _ProcessPpt($sFile) Func _ProcessPpt($sFile) $oApp = _PPT_PowerPointApp() Local $bChange = False Local $oInterface = $oApp.Presentations Local $oPresentation = $oInterface.Open($sFile, False, False, False) If @error Then _FileWriteLog($sFullLogFile, "E Error " & @error & " opening File " & $sFile) Return SetError(1, 0, 0) EndIf ;it does not even open my file and from here not sure how to read the text and replace it EndFunc ;==>_ProcessPpt  
    • YellowLab
      By YellowLab
      I am having a very unique, but repeatable problem with ImageMagick COM interface. Here are the applicable lines of code:
      $oIM=ObjCreate("ImageMagickObject.MagickImage.1")
      and then later on...
      $oIM.Convert(String($arFileList[$nFileIndex])&'[0]',"-alpha", "remove",@TempDir&"\temp.jpg")
      the array points to a pdf file with the "convert" command converting the first page of the pdf to a jpg with any alpha layer removed.
      Every time, without fail, the first time I run the script on a freshly booted machine it crashes on the $oIM.Convert command. It does this if it isn't compiled and says there is an error executing the command on the object. If compiled, i get an error that autoit has stopped responding. Anytime I run the script, compiled or not, after this initial crash everything works perfectly fine.
      I am totally at a loss as to why this is occurring and how to correct it.
    • Javik
      By Javik
      Is there a way to read data directly from the Windows Component Object Model (COM) interface?
      I am trying to make a really simple disk space reporter tool for accounts on an Active Directory domain, to read the disk quota limit for the logged on user's home directory, and report how much disk space they are currently using.
      ,
      MSDN:  IDiskQuotaUser interface
      https://msdn.microsoft.com/en-us/library/windows/desktop/aa365033(v=vs.85).aspx
      GetQuotaLimit
      GetQuotaUsed
       
       
    • WoodGrain
      By WoodGrain
      Hi All,
      I've coded the small script below, but it can't seem to get the instance of Windows Media player as it keeps going to @error, I've not used com objects before so any assistance would be appreciate. I already have WMP open and minimised. I retrieved "WMPlayerApp" from the AutoIT info tool, I've included a copy below.
      I'm using these sources:
      https://msdn.microsoft.com/en-us/library/dd564085.aspx
      https://msdn.microsoft.com/en-us/library/dd564018.aspx
      $oWMP = ObjGet("", "WMPlayerApp") If @error Then MsgBox(0, "Can't get WMP", "Couldn't connect to the WMP instance") Exit EndIf $wmpPlayState = $oWMP.playState MsgBox(0, "Play State", $wmpPlayState) $wmpSongName = $oWMP.currentMedia.name MsgBox(0, "Play State", $wmpSongName) I've also seen references to the below, but I want to get an existing open WMP:
      ObjCreate("wmplayer.OCX") and have looked at the WMP.udf but can't see how it will do either of the functions I've coded above.