Jump to content

Update links Powerpoint


Stoldak
 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...