Page 1 of 1 1
Topic Options
#197738 - 2010-02-10 07:30 PM Determine if one spreadsheet has a link to another
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
Hello everyone,

I am going to be moving data from one file server to a different file server with a different directory structure. My biggest hiccup is what to do about Excel spreadsheets that are linked to other spreadsheets. Once I move them the links will be broken until they are manually updated.

While I understand that this has to be the case, it would be nice to know which spreadsheets are going to break BEFORE I break them.

So my question is can I use KiXtart to check out my spreadsheets and see if there are any links?

thanks for any help you can give.

Jason

Top
#197742 - 2010-02-11 01:15 AM Re: Determine if one spreadsheet has a link to another [Re: jadewith]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
MrExcel Link Hacker Add-In
http://www.mrexcel.com/store/index.php?l=product_detail&p=11
$45.00


Top
#197747 - 2010-02-11 08:49 PM Re: Determine if one spreadsheet has a link to another [Re: jadewith]
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
That looks like the trick Doc, Thanks!

I wonder though, is there a way to do it using KiXtart?

Top
#197749 - 2010-02-11 10:51 PM Re: Determine if one spreadsheet has a link to another [Re: jadewith]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I'd bet there is, but maybe it's just me, but $45 seems cheaper than hours of headaches to do it yourself.
Top
#197750 - 2010-02-12 12:36 AM Re: Determine if one spreadsheet has a link to another [Re: Allen]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Shouldn't you be able to get this informaton from -

LinkSources Method [Excel 2003 VBA Language Reference]

or from -


How to find if a workbook contains references to other workbooks?

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#197751 - 2010-02-12 12:39 AM Re: Determine if one spreadsheet has a link to another [Re: Kdyer]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Both of those methods only tell you if it has a link. It does not fix it. I'm sure there is documentation somewhere though on how to do it but for the $45 I bought it last year when I moved thousands of linked documents to a new location and it seemed to work well for me. I'm not sure if it works on Office 2007 worksheets though as I didn't have any back then.
Top
#197752 - 2010-02-12 11:22 AM Re: Determine if one spreadsheet has a link to another [Re: NTDOC]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here's a KiXtart solution to get you started that will go and find workbooks with links.

You can run this to check the files to see if you're going to have a major problem, and then decide whether you want to buy the commercial product or engineer another solution.

No major testing done, in particular if the links are anything other than simple strings expect an abend that you'll need to code around.

 Code:
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

Top
#197796 - 2010-02-17 10:11 PM Re: Determine if one spreadsheet has a link to another [Re: Richard H.]
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
Richard,

Thanks, that's exactly what I was looking for. Precursory testing has not revealed any complex links that would cause an abend, as you warn may happen.

Thanks again.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.159 seconds in which 0.091 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org