beisaikong Posted March 17, 2018 Share Posted March 17, 2018 hi i was writing a simple code below #include-once #include <StringConstants.au3> #include <PowerPointConstants.au3> #include <Constants.au3> #Region Include #include <PowerPoint.au3> $objPPT = _PPT_Open(True) $objPres = _PPT_PresentationOpen($objPPT, "H:\Auto\Test.ppt") MouseClick($MOUSE_CLICK_LEFT,1000,600,1) Send("{DEL 1}") MouseClick($MOUSE_CLICK_LEFT,1000,600,1) $objTest = _PPT_SlideAddPicture($objPres,"H:\Auto\_MG_7551.jpg",0,0,100,100) the last part of adding a picture did not work, there is no error and nothing happen. anyone can help ? regards beisaikong Link to comment Share on other sites More sharing options...
water Posted March 17, 2018 Share Posted March 17, 2018 What's the value of @error and @extended after calling _PPT_SlideAddPicture? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 17, 2018 Author Share Posted March 17, 2018 @error shows 3 and @extended shows 0. what does it means ? Link to comment Share on other sites More sharing options...
water Posted March 17, 2018 Share Posted March 17, 2018 Seems you are using this PowerPoint UDF: @error 3 means, that one of the parameters left, top, width, height is missing or wrong. Func _PPT_SlideAddPicture(ByRef $obj, $filepath, $left = 0, $top = 0, $width = 100, $height = 100) But the code you post seems to be correct Do you really run the code you posted? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 17, 2018 Author Share Posted March 17, 2018 the udf you mention is my powerpoint1.au3. this udf have the slideaddpicture. the previous code, i just copy this slideaddpicture function into the powerpoint.au3 same results whether i use either udf #include-once #include <StringConstants.au3> ;#include <PowerPointConstants.au3> #include <Constants.au3> #Region Include #include <PowerPoint1.au3> $objPPT = _PPT_PowerPointApp(1) $objPres = _PPT_PresentationOpen($objPPT, "H:\Auto\Test.ppt") MouseClick($MOUSE_CLICK_LEFT,1000,600,1) Send("{DEL 1}") MouseClick($MOUSE_CLICK_LEFT,1000,600,1) $objTest = _PPT_SlideAddPicture($objPPT,"H:\Auto\_MG_7551.jpg",0,5,105,100) Link to comment Share on other sites More sharing options...
water Posted March 17, 2018 Share Posted March 17, 2018 Mixing two UDFs is not supported and errors are hard to find. But I think the problem is caused by the following fact: Neither the PowerPoint application object (referenced by $objPPT in your script) nor the presentation object (referenced by $objPres) offers a shape object as being used in function _PPT_SlideAddPicture. You need to access a slide and pass the slide object to function _PPT_SlideAddPicture. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 18, 2018 Author Share Posted March 18, 2018 i can use just one udf. i had the same suspicion but i already have an existing presentation with 1 slide. i do not see any function in the udf which will just assess a slide ? Link to comment Share on other sites More sharing options...
water Posted March 18, 2018 Share Posted March 18, 2018 I think it should work when you specify the slide object: $objTest = _PPT_SlideAddPicture($objPres.Slides(1), "H:\Auto\_MG_7551.jpg", 0, 5, 105, 100) Should add the picture to slide 1. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 18, 2018 Author Share Posted March 18, 2018 Give me this error. error: _PPT_SlideAddPicture() called with Const or expression on ByRef-param(s). Link to comment Share on other sites More sharing options...
beisaikong Posted March 18, 2018 Author Share Posted March 18, 2018 i did some testing and with new presentation and new slide, it works. Opening an existing presentation need some tweaking it seems. Link to comment Share on other sites More sharing options...
water Posted March 18, 2018 Share Posted March 18, 2018 5 minutes ago, beisaikong said: Give me this error. error: _PPT_SlideAddPicture() called with Const or expression on ByRef-param(s). Then pass the slide object as a variable: $objSlide = $objPres.Slides(1) $objTest = _PPT_SlideAddPicture($objSlide, "H:\Auto\_MG_7551.jpg", 0, 5, 105, 100) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 18, 2018 Author Share Posted March 18, 2018 now it worked. thanks how do you know that .slides is like a property of $objPres ? since now $objTest is a picture object, how can i send the picture to the background ? Link to comment Share on other sites More sharing options...
water Posted March 18, 2018 Share Posted March 18, 2018 $objTest is a Shape object. The following method allows to move a shape to the background: https://msdn.microsoft.com/en-us/library/ff744516(v=office.14).aspx My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 19, 2018 Author Share Posted March 19, 2018 can't seems to use the $objTest.ZOrderPosition or $objTest.ZOrder direct off the shape object. it is not doing anything. any thoughts ? Link to comment Share on other sites More sharing options...
water Posted March 19, 2018 Share Posted March 19, 2018 Can you please post the code you run? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted March 19, 2018 Share Posted March 19, 2018 The MSOZOrderCmd enumeration can be found here: https://msdn.microsoft.com/en-us/library/aa432726(v=office.12).aspx My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 20, 2018 Author Share Posted March 20, 2018 here is the code #include <StringConstants.au3> #include <Constants.au3> #include <PowerPoint1.au3> #include <misc.au3> $objPPT = _PPT_PowerPointApp() $objPres = _PPT_PresentationOpen($objPPT, "H:\Auto\Test.ppt") $objSlide = $objPres.Slides(1) $objPicture = _PPT_SlideAddPicture($objSlide, "H:\Auto\MG_7551.jpg",-1,-1,721,542) $objPicture.ZOrder = 1 Link to comment Share on other sites More sharing options...
water Posted March 20, 2018 Share Posted March 20, 2018 The function from the old PowerPoint UDF does not return the Shapes object. So you can't access $objPicture in your script. This code does not rely on the old UDF and works: #include <PowerPoint.au3> $oPPT = _PPT_Open() $oPres = _PPT_PresentationOpen($oPPT, @ScriptDir & "\Presentation1.pptx") $oSlide = $oPres.Slides(1) $oPicture = _PPT_SlideAddPicture($oSlide, @ScriptDir & "\Microsoft_PowerPoint_2013_logo.png", -1, -1, 721, 542) $oPicture.ZOrder(1) Func _PPT_SlideAddPicture(ByRef $obj, $filepath, $left = 0, $top = 0, $width = 100, $height = 100) If IsObj($obj) <> 1 Then SetError(1) Return 0 ElseIf FileExists($filepath) <> 1 Then SetError(2) Return 2 ;file does not exist ElseIf $left = "" Or $top = "" Or $width = "" Or $height = "" Then SetError(3) Return 3 ElseIf IsInt($left+$top+$width+$height) <> 1 Then SetError(4) Return 4 ;All parameters have to be integer Else Return $obj.Shapes.AddPicture($filepath, 0, 1,150, 150, 500, 350) Endif EndFunc My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
beisaikong Posted March 21, 2018 Author Share Posted March 21, 2018 try the code you suggested. the newly added picture was not send to back. i am using powerpoint 2010. #include <StringConstants.au3> #include <Constants.au3> #include <PowerPoint.au3> #include <misc.au3> $oPPT = _PPT_Open() $oPres = _PPT_PresentationOpen($oPPT, "H:\Auto\Test.ppt") MouseClick($MOUSE_CLICK_LEFT,1000,600,1) Send("{DEL 1}") $oSlide = $oPres.Slides(1) $oPicture = _PPT_SlideAddPicture($oSlide, "H:\Auto\MG_7551.jpg", -1, -1, 721, 542) $oPicture.ZOrder(1) Link to comment Share on other sites More sharing options...
water Posted March 21, 2018 Share Posted March 21, 2018 What do you mean with "send to background"? Should the picture become invisible? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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