Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Filecopy in vba macro

Hello,

I am trying to write a vba macro which saves my whole
bunch of excel files using a wild card, Like "*.xls". Is
FILECOPY in vba accepts wildcard, if not, Any suggestion
or ideas on how to save excel files with a wildcard?

Appreciate your help.

Thanks
Julio

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Filecopy in vba macro

Julio,

My experience is that you cannot save files using a
wildcard.

However, you can read the contents of a directory into an
array. You could then loop through the array and move all
of the files. This assumes that the files are not open.
You would copy the files using Windows API calls.

public sub FileList( FilePath as String )

DIM varFileListArray as Variant Array

* the windows api command Dir I think returns a
* Vector(?) array containing a list of file names
varFileListArray = Dir ( FilePath )

DO WHILE More_Files TRUE
Dim i As Integer
' original file location
OldFilePath = "C:\OldFolder\" + varFileListArray[i]
' new file location
NewFilePath = "C:\NewFolder\" + varFileListArray[i]

' move the file
Name OldFilePath As NewFilePath

NEXT i

Obviously that won't compile, but it should give you the
basics enough to figure out exactly what needs to be done.

If the files are open, you can simply call each workbooks
save or save as function.

John.


-----Original Message-----
Hello,

I am trying to write a vba macro which saves my whole
bunch of excel files using a wild card, Like "*.xls". Is
FILECOPY in vba accepts wildcard, if not, Any suggestion
or ideas on how to save excel files with a wildcard?

Appreciate your help.

Thanks
Julio

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
filecopy Question rjvega Excel Discussion (Misc queries) 2 July 8th 08 09:12 PM
FileCopy Dana DeLouis[_5_] Excel Programming 0 August 11th 03 12:57 PM
FileCopy John Green[_2_] Excel Programming 1 August 5th 03 08:55 AM
FileCopy error Chip Pearson Excel Programming 0 August 1st 03 02:43 PM


All times are GMT +1. The time now is 10:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"