
beisaikong
Active Members-
Posts
23 -
Joined
-
Last visited
beisaikong's Achievements

Seeker (1/7)
0
Reputation
-
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
looks okay now. i use array for the picture object. but one flaw is the saveas can't seems to work without creating a new folder everytime even putting in a full path $Photo = 1 Local $oPicture[5] while $Photo < 6 $oPPT = _PPT_Open() $oPres = _PPT_PresentationOpen($oPPT, @ScriptDir & "\Test.ppt") $oSlide = $oPres.Slides(1) $oSlide.Shapes(1).Delete $oPicture[$Photo] = _PPT_SlideAddPicture($oSlide, @ScriptDir & "\" & $Photo & ".jpg", -1, -1, 721, 542) $oPicture[$Photo].ZOrder(1) _PPT_PresentationSaveAs($oPres, @ScriptDir&"\New" & $Photo, 17) _PPT_PresentationClose($oPres) _PPT_Close($oPPT) $Photo = $Photo + 1 WEnd -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
i think i found the problem. need to use a new picture object everytime but since it is an object variable. how do i make use of a new variable everytime the loop runs ? using an if else doesn't seems right if $Photo = 2 Then $oPicture = _PPT_SlideAddPicture($oSlide, @ScriptDir & "\" & $Photo & ".jpg", -1, -1, 721, 542) $oPicture.ZOrder(1) Else $oPicture1 = _PPT_SlideAddPicture($oSlide, @ScriptDir & "\" & $Photo & ".jpg", -1, -1, 721, 542) $oPicture1.ZOrder(1) EndIf -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
yup did what you suggested. first time in the loop both was 0, second time in the loop both was 0 as well then it crashed. -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
that error is gone now but somehow the script still crashed @@ Trace(32) : ;MsgBox(0,"111",$Photo) >Error code: 0 @@ Trace(35) : $oPicture.ZOrder(1) "H:\Auto\Test.au3" (35) : ==> The requested action with this object has failed.: $oPicture.ZOrder(1) $oPicture^ ERROR ->20:53:04 AutoIt3.exe ended.rc:1 +>20:53:04 AutoIt3Wrapper Finished. >Exit code: 1 Time: 6.042 -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
i added traces to every line and got the below. not sure if it is related to the zorder crashing the script. @@ Trace(38) : _PPT_PresentationSaveAs($oPres, @ScriptDir&"\New", 17) >Error code: 3 -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
the mouseclick is to select the picture in the ppt and then delete it away before i add the new picture. quick and dirty. i removed the sending mouse and keystroke but it still crashed the second time in the loop. it crashed after $oPicture.Zorder(1). before that, error and extended are both 0. $Photo = 1 while $Photo < 6 $oPPT = _PPT_Open() $oPres = _PPT_PresentationOpen($oPPT, @ScriptDir & "\Test.ppt") $oSlide = $oPres.Slides(1) $oSlide.Shapes(1).Delete $oPicture = _PPT_SlideAddPicture($oSlide, @ScriptDir & "\" & $Photo & ".jpg", -1, -1, 721, 542) ;MsgBox(0,"111",$Photo) MsgBox(0, "Result", "@error = " & @error & ", @extended = " & @extended) $oPicture.ZOrder(1) MsgBox(0, "Result", "@error = " & @error & ", @extended = " & @extended) _PPT_PresentationSaveAs($oPres, @ScriptDir&"\New", 17) ;_PPT_PresentationSaveAs($oPres, @ScriptDir & "\New" & "\" & $Photo & ".jpg", 17) _PPT_PresentationClose($oPres) _PPT_Close($oPPT) $Photo = $Photo + 1 ;MsgBox(0,"222",$Photo) WEnd -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
i was trying to loop this but when the loop was running the second time, it just crashed with below. couldn't see any errors "H:\Auto\Test.au3" (17) : ==> The requested action with this object has failed.: $oPicture.ZOrder(1) $oPicture^ ERROR $Photo = 1 while $Photo < 6 $oPPT = _PPT_Open() $oPres = _PPT_PresentationOpen($oPPT, @ScriptDir & "\Test.ppt") MouseClick($MOUSE_CLICK_LEFT,1000,600,1) Send("{DEL 1}") $oSlide = $oPres.Slides(1) $oPicture = _PPT_SlideAddPicture($oSlide, @ScriptDir & "\" & $Photo & ".jpg", -1, -1, 721, 542) MsgBox(0,"111",$Photo) $oPicture.ZOrder(1) _PPT_PresentationSaveAs($oPres, @ScriptDir&"\New", 17) ;_PPT_PresentationSaveAs($oPres, @ScriptDir & "\New" & "\" & $Photo & ".jpg", 17) _PPT_PresentationClose($oPres) _PPT_Close($oPPT) $Photo = $Photo + 1 MsgBox(0,"111",$Photo) WEnd -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
i was trying the above code before but it will save each slider to a new jpg. since we did not indicate the filename each time, how does it know ? i see that the saveas function overwrite is false so it should not overwrite. i was expecting it to save the second time as Slide2.jpg -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
same results. it does not work. i was thinking if it is a permission issue but if it can create the folder and probably not a permission issue. -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
Msgbox(0,"123","aaa") _PPT_PresentationSaveAs($oPres, "123.jpg", 17) MsgBox(0, "Result", "@error = " & @error & ", @extended = " & @extended) strangely, the second message box did not appear. -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
trying the save as function. i remove the format default. regarding the filepath, the below code created a folder 111 and then save the file as Slide1.jpg _PPT_PresentationSaveAs($oPres, "H:\Auto\111", 17) the saveas method seems to be below SaveAs( Filename, FileFormat, EmbedFonts ) Filename - Specifies the name to save the file under. If you don't include a full path, PowerPoint saves the file in the current folder. if i try the below, then nothing happens _PPT_PresentationSaveAs($oPres, "123.jpg"", 17) Func _PPT_PresentationSaveAs($oPresentation, $sFilePath, $iFormat, $bOverWrite = Default) If Not IsObj($oPresentation) Or ObjName($oPresentation, 1) <> "_Presentation" Then Return SetError(1, 0, 0) If $iFormat = Default Then $iFormat = $ppSaveAsDefault Else If Not IsNumber($iFormat) Then Return SetError(2, 0, 0) EndIf If $bOverWrite = Default Then $bOverWrite = False If FileExists($sFilePath) Then If Not $bOverWrite Then Return SetError(3, 0, 0) Local $iResult = FileDelete($sFilePath) If $iResult = 0 Then Return SetError(4, 0, 0) EndIf $oPresentation.SaveAs($sFilePath, $iFormat) If @error Then Return SetError(5, @error, 0) Return 1 EndFunc ;==>_PPT_PresentationSaveAs -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
it works now. apparently i have a slideaddpicture function in powerpoint.au3. it was missing a return. now i am going to try to save the ppt as a jpg file -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
sorry, i mean "send to back". my ppt has other pictures, for the newly added one, i want to "send to back" if i right click the picture, there is a "send to back" -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
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) -
add a picture to a powerpoint slide
beisaikong replied to beisaikong's topic in AutoIt General Help and Support
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