Solved

Script to Read Excel Files

Posted on 2015-02-13
13
105 Views
Last Modified: 2015-03-18
Hello,

I have a network share with a series of folders and sub folders in it and I am looking for a way in which I can identify and look at each Excel file and when a value in a certain cell is identified it captures the Path of that file?

I am not sure which technology or approach would be best for this or whether this is indeed possible - any help would be great and any example scripts even better. The value I am looking for is always in the same place - on a tab called "Sheet Summary" and in Cell B47.

Thanks in advance

GISVPN
0
Comment
Question by:gisvpn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
13 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40607485
It is possible - see this article about "Reading document properties in multiple files", which shows how to go through a folder and open each spreadsheet in turn.

Instead of looking at the Author property as mentioned in that article

ActiveWorkbook.BuiltinDocumentProperties("Author")

you would probably want

ActiveWorkbook.Sheets("Sheet Summary").cells(47,2)

The rest of the code should work fine for you.
0
 

Author Comment

by:gisvpn
ID: 40607622
Hi Philip,

This works great. Two questions you may be able to help me with.

- this errors out as soon as it hits an excel file where there is no Sheet Summary tab - how can I simply ask it to ignore any spreadsheet where it cannot find the summary tab?
- Do you know how I can capture the full file paths for that file?

I would like to add in Column C: but not sure what I need to put in xx?

mySheet.Cells(introw, 3) = xx?

It looks for strExtension = "*.xls*"  how can I add Xlsx and Xlsm to this too?

Many thanks!

GISVPN
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40607626
>> - this errors out as soon as it hits an excel file where there is no Sheet Summary tab

It shouldn't do if you have the line

On Error GoTo MyError

in.

>> Do you know how I can capture the full file paths for that file?

mySheet.Cells(introw, 1) = strFolder & "/" & strFile

>> I would like to add in Column C: but not sure what I need to put in xx?

mySheet.Cells(introw, 3) = ActiveWorkbook.Sheets("Sheet Summary").cells(47,3)

>> It looks for strExtension = "*.xls*"  how can I add Xlsx and Xlsm to this too?

It already does - that's what the end star * is for. It will look for anything containing .xls; not nessarily just .xls, but .xlsb, .xlsm etc.
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:gisvpn
ID: 40607629
Oh I Just noticed that this when it runs DIR does not include subfolders?

strFolder = "C:\test\"

could I amend this to include this folder and all subfolders?
0
 

Author Comment

by:gisvpn
ID: 40607950
Hi Philip - thanks for the post above, the above worked many thanks! Let me know if you can answer the question above on being able to expand the scope of the script to cover sub folders too.
0
 

Author Comment

by:gisvpn
ID: 40614356
hi Phillip - not sure if you can help with the last question on whether you can ensure subfolders are included - would this be something that can be done at all?
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40614434
I've got a few ideas, but they would take some time do.

Basically, you use another DIR to go through the subfolders, and then catalog each of those folders. However, it would take some time to implement.
0
 

Author Comment

by:gisvpn
ID: 40614444
Hi Phillip,

Thanks for the reply - would it take time to execute or time to create a script that would be able to do this?

Regards,

GISVPN
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40614447
Time to create.
0
 

Author Comment

by:gisvpn
ID: 40614585
ok - if you have any suggestions please let me know! This is a key part of the script/requirement - a pity it is not an easy amendment to where the script points!
0
 

Author Comment

by:gisvpn
ID: 40620660
If anyone else can help with this question it would be greatly appreciated. The script offered here is what is required but I would like to know if there is a simpler/better approach to ensure sub folders are in scope of the script too when run.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40672897
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question