[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Script to Read Excel Files

Posted on 2015-02-13
13
Medium Priority
?
109 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 49

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

656 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