Jump to content
Stoldak

Update links Powerpoint

Recommended Posts

Stoldak

Hello,

pls can you help me with simple autoit script.

I need to open powerpoint ppt, update all links and close it. I have got everything except update links. Here is a code:

#include <PowerPoint.au3>

$objPPT = _PPT_PowerPointApp()

$objPres = _PPT_PresentationOpen($objPPT, "S:\Back Office VIP\Projekty\WB OUTBOUND\wallboard.ppt")

_PPT_UpdateLinks = ($objPPT)

_PPT_PresentationSaveAs($objPres, "S:\Back Office VIP\Projekty\WB OUTBOUND\wallboard.ppt")

_PPT_PresentationClose($objPres) ; Close presentation

_PPT_PowerPointQuit($objPPT)

 

I am using PPT wrapper and everything is ok, only update links. I try to write a function

Func _PPT_UpdateLinks($obj)
    If IsObj($obj) <> 1 Then
        SetError(1)
        Return 0
    Else
        Return $obj.Updatelinks
    Endif
EndFunc

 

But when I use in first code, debug told me: Statement cannot be just an expression.

 

Pls help, thanks

 

Share this post


Link to post
Share on other sites
water

I once wrote a script to modify links in Word, Excel and PowerPoint. This is the function for PowerPoint.

Func _ProcessPpt($sFile, $szFName, $szExt)

    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
    For $oSlide In $oPresentation.Slides
        For $oHyperLink In $oSlide.Hyperlinks
            If StringInStr($oHyperLink.Address, $sString2Search) > 0 Then
                $oHyperLink.Address = StringReplace($oHyperLink.Address, $sString2Search, $sString2Replace, $iReplaceOnce)
                $bChange = True
            EndIf
            If StringInStr($oHyperLink.TextToDisplay, $sString2Search) > 0 Then
                $oHyperLink.TextToDisplay = StringReplace($oHyperLink.TextToDisplay, $sString2Search, $sString2Replace, $iReplaceOnce)
                $bChange = True
            EndIf
        EndIf
    Next
    If $bChange = True Then ; If replace occurred
        $oPresentation.Save()
        If @error Then
            _FileWriteLog($sFullLogFile, "E Error " & @error & " when saving file " & $sFile)
            Return SetError(3, 0, 0)
        EndIf
        $oPresentation.Close()
        _FileWriteLog($sFullLogFile, "I " & $sFile & " successfully saved.")
        Return -1
    EndIf
    $oPresentation.Saved = True
    $oPresentation.Close()
    Return 1

EndFunc   ;==>_ProcessPpt

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
Stoldak

I am a little noob in this :)  This function I will put in PowerPoint.au3 and I will call it in my script?

Something like:

_ProcessPpt($sFile, $szFName, $szExt)
$sFile = path to file

other attributes?

thx

Share this post


Link to post
Share on other sites
water

You could drop $szFName and $szExt as they are not used in the function. $sFile is the full path to the PowerPoint file.
All other variables are Global:

$sString2Search - String to search for (old text)
$sString2Replace - Replacement string (new text)
$iReplaceOnce - How often do you want to replace the string (>= 1)
$sFullLogFile - Full path to the logfile (lines writing to the log file can be dropped if not needed)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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

×