Break ON
$=SetOption('Explicit','ON')
$=SetOption('WrapAtEOL','ON')
; Create a global instance of Excel to avoid the overhead of opening it continually.
Global $__oExcel
$__oExcel=CreateObject('Excel.Application')
If Not 9=VarType($__oExcel) 'Cannot create Excel applciation'+@CRLF Exit @ERROR EndIf
; Enable the next line to watch the sheets open.
$__oExcel.Visible=-1
Dim $sStartDir $sStartDir='C:'
Dim $sFileTrigger $sFileTrigger='Exit Right($$sPayload,4)=".xls"'
Dim $sFileAction $sFileAction='fixExcelLinks($$sPayload)'
$=funProcessFiles($sStartDir,$sFileTrigger,$sFileAction)+@CRLF
$__oExcel.Quit
Exit 0
Function funProcessFiles($sStart,$sTrigger,$sAction)
Dim $sPayload,$sEntry
If Not 16 & GetFileAttr($sStart) Exit 0 EndIf
$sEntry=Dir($sStart)
While Not @ERROR
If $sEntry='.' or $sEntry='..'
; Ignore self and parent
Else
$sPayload=$sStart+'\'+$sEntry
If Execute($sTrigger)
If Execute($sAction) Exit 2 EndIf
EndIf
If 16 & GetFileAttr($sPayload) funProcessFiles($sPayload,$sTrigger,$sAction) EndIf
EndIf
$sEntry=Dir()
Loop
Exit 0
EndFunction
Function fixExcelLinks($sPath)
Dim $oWorkbook,$vDiscard,$sLink
'Checking Excel file: '+$sPath+@CRLF
$oWorkbook=$__oExcel.workbooks.Open($sPath)
If 9=VarType($oWorkBook)
If VarTypeName($oWorkBook.LinkSources())='Empty'
' No links found'+@CRLF
Else
For Each $sLink in $oWorkBook.LinkSources()
'***LINK: '+$sLink+@CRLF
Next
EndIf
$oWorkbook.Saved=-1
$vDiscard=$oWorkbook.Close(0)
EndIf
EndFunction