Link to home
Create AccountLog in
Avatar of Howard Bash
Howard BashFlag for United States of America

asked on

Office Automation

I have a project where I need to go through a network share and analyze the office files I find.  I need build a list of all the found files including a sublist for each of their linked and/or embedded files.

I will need that list and then to adjust all the names within to meet a naming requirement and modify the office file links and names accordingly.

Avatar of cy_hung
cy_hung
Flag of Hong Kong image

What's the meaning for linked and/or embedded files ? do you means the hyperlinks in either word / excel ?
Avatar of Howard Bash

ASKER

Yes.  You can add hyperlinks to files as well as use sections of spreadsheets in another file for calculations in a "maste" spreadsheet.
Avatar of Anastasia D. Gavanas
could we see a sample?
so you need a function/script that will
(1) search/look at a particular location/folder and all subfolders on the drive for OFFICE files (ie xls, doc, ppt, etc)
Please specify what kind of files are you looking for
(2) open the files and inspect them in regards of hyperlinks
If a hyperlink is found write its name and location to a list

correct?
Read Office Word and Excel files from share (iterate throught sub folders) and for each found file, locate hyperlinks and references to other "some file"/workbook/sheets/cells.

Examples: In myfile.xls cell A1 could refer to the following (note the filename in the formula)

=SUM([Budget.xlsx]Annual!C10:C25)
=SUM('C:\Reports\[Budget.xlsx]Annual'!C10:C25)
=SUM(Budget.xlsx!Sales)




What you are asking is actually quite complex - both Word and especially Excel have several different places where they store links (e.g hyperlinks, ordinary external formula references, external links to pivot table data, external data queries, OLE links, etc).  There are paid-for 3rd party products that will do this for you if you have a big requirement - Link Fixer Pro is one that I believe is good, although I haven't personally used it.

I do have some code that is part of a much bigger scanning process I wrote a while ago that identifies all types of links in Word and Excel.  I will try to extract out and post just the releveant chunks of code.  The other think you need to consider when doing this sort of thing is that the error handling needs to be quite comprehensive when you are looking to open arbitrary numbers Excel files, which may use add-ins you don't have access to, be password protected, etc, etc.
Yes, it is quite a complex issue that requires error handling to address issues such as you have mentioned. I would love to see some relevant chunks of good.  I think I spend much of my time looking for snippets that either give me more insight(s) or that I can use as a basis for some essential function(s).
SOLUTION
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
You reference a an AddLinkItems.  Can you explain this object?
OK - that's not important, it's just a routine I have to generate my output report, which is xml based. The only thing you might need to take from this is the second parameter, which is the details of the link.  As you can see, I also pass the file name, the type of link, and the sheet name, but this is just for reporting purposes.