Many Thanks for Scripting.FileSystemObject
Regards
"Jim Cone" wrote:
> A Set statement is used for objects only.
> Path is a String, so "Set WbSource.Path = " will cause an error.
> For moving files/folders I prefer using the Scripting Runtime FileSystemObject.
> When you use a wild card "*", all files of the particular type are moved.
> The following code copies all .xls files from one folder to another.
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
>
> '------------------------
> Sub CopyFilesWithScriptingRuntime()
> Dim strFromPath As String
> Dim strToPath As String
> Dim Fso As Object
>
> 'The * can only be used in the last position.
> strFromPath = "C:\Mis documentos\10 October 2005\*.xls"
> 'The * cannot be used in the destination path.
> strToPath = "C:\Mis documentos\12 December 2005"
>
> Set Fso = CreateObject("Scripting.FileSystemObject")
>
> 'Copy all of the .xls files - False prevents overwriting of files
> Fso.CopyFile strFromPath, strToPath, False
> Set Fso = Nothing
> End Sub
> '--------------------
>
>
> "TISR" <TISR@discussions.microsoft.com>
> wrote in message
> news:00770E6F-AC79-4C98-9B6E-207C574F10B8@microsoft.com...
> I want to copy a number of files from one folder to another
> The code that I am trying to use is:
> Dim WbSource As Workbook
> Set WbSource.Path = "C:\Mis documentos\10 October 2005"
> For Each Workbook In WbSource.Path
> Workbook.Copy "C:\Mis documentos\12 December 2005"
> Next Workbook
> However it tells me that I am making wrong use of Path
> Can someone help?
>
Bookmarks