adding a refresh button is not difficult either. We would just move the code from your existing VB macro into a OnClick event function, or we can have it refresh on an interval also.
Main Topics
Browse All TopicsI am new to VBscript and have limited knowledge of Macros. I have searched around trying to find a macro or script to combine multiple excel files that are generated individually from Reporting Services in SQL into one excel file, and have each file as a worksheet in the file. There are several scripts that will do this, but only as the macro is run or by selecting the files. I need to have this run behind the scenes and pull the files automatically when the combined master file is opened. My thought was to have the reports that are being generated to go to specific folders with generic file names. For example Report1 folder will have files File1, File2, and File3. Then have the master file in a different location that when opened will pull these files to help refresh the data.
The problems that I am running into are that I can't find a macro or VBscript that will do this automatically.
I have users utilizing these reports that can't be asked to run several steps to combine the files, because it would be to confusing.
Finally, some of the reports are run every minute or 15 minutes to help keep the reports current and up to date, because these spreadsheets are used all day long for tracking and organizing. So, I need the master file to refresh when open or be able to refresh with a single click while the file is open.
Does anyone have any macros or scripts that I could use that would accomplish these tasks?
Thanks in advance for your help!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry for the delayed response...I was unavailable for a couple of days. I have attached the scripts attached. I have been in the process of modifying the code and trying to create a solution, but I have not figured it out yet. The original code, some of which I have commented out, prompts the user to pick a file and then proceeds to use the path to pull other excel files in as worksheets within the open excel file. It also had a feature that alphabetized the worksheets, which I don't have a need for, so I commented it out.
I was trying to modify it to open the file desired, specify the path and not prompt the user. Also, I think a refresh button would be great for the file, because the master file is one that will remain open throuhout the day by multiple people and having the ability to refresh the data without having to close out would be ideal.
Thanks again for the help!
For opening the *.xls files in a specified directory, check out this function:
http://msdn.microsoft.com/
What you do is call the Dir$ function like:
R = Dir$("C:\path\*.xls")
check to make sure that a file exists with that extension (you don't *have* to)
R will contain a filename at the path that has the extension of *.xls.
Read the MSDN helpfile, you can loop through the return values of Dir$ until the function returns nothing.
Hope this helps. Post back your thoughts, and what next you want to work on.
Business Accounts
Answer for Membership
by: opsterPosted on 2009-01-29 at 14:00:40ID: 23503206
You need to start with one of the scripts you have already found and modify it.
You say you have a script that does everything you want, but requires someone to manually run the script. You can Convert this script into an exe or a bat file and run it as a scheduled task, and simply modify the file selection portion to automatically select all files in a specified directory.
Post the scripts you have found with a description of what they do and I can assist you in learning how to modify them to do what you want.