Solved

Script to Read Excel Files

Posted on 2015-02-13
13
100 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
  • 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 45

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now