Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2003, 12:38 PM
Registered User
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Auto Open Files

Please does anyone know how to open all the files in a folder one at a time, without knowing their names. I did it with an excel 4 macro using "open next" but there does not seem to be an equivalent command in VBA.
             Many thanks

Hugh Gunn
 
Old December 17th, 2003, 01:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need to use the 'dir' command
Code:
Fullname = Dir(DOWNLOAD_PATH & FILE_MASK & "*" & FILE_EXT, vbNormal)

While Fullname <> ""

    Workbooks.Open Filename:=DOWNLOAD_PATH & Fullname
FullName = Dir() 'used without arguments, takes the next file in the directory
Wend
set FILE_MASK = Sales, FILE_Ext = .XLS to an effective file search on Sales*.xls, for example.

Chris


There are two secrets to success in this world:
1. Never tell everything you know





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pdf files doesn't open Ciupaz BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 2 September 11th, 2008 04:36 PM
Error on trying to open passworded files southernsun Beginning VB 6 2 March 25th, 2008 10:32 AM
Generate summ rpt,auto send fr various excel files miracles Excel VBA 2 March 29th, 2007 03:45 AM
Generate summ rpt,auto send fr various excel files miracles Excel VBA 0 March 28th, 2007 02:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.