Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Modules _ Fso.copyfile With Wildcard

Posted by: AAJONES3 Mar 26 2020, 01:43 PM

I'm running the following code but it's not understanding the correct source file. My source file is \\\Shares\Open_2020-03-26_10-02-PM.xlsx

Dim strBasePath As String
Set fso = CreateObject("Scripting.FileSystemObject")
strFilter = Format(Now(), "yyyy-mm-dd") & "_10" & "*AM.xlsx"
strSourceFile = "\\\Shares\Open_" & strFilter
strDestinationPath = "C:\Users\Public\Sources\Open10am.xls"
Call fso.CopyFile(strSourceFile, strDestinationPath)

If I put a msgbox to recall what the strsourcefile is, it's including the * as a string rather than wildcard: \\\Shares\Open_2020-03-26_10*AM.xlsx iconfused.gif

Posted by: esancha Mar 26 2020, 03:39 PM

As indicated by the FileSystemObject help Wildcard characters can only be used in the last path component of the source argument. For example, you can use:

fso.CopyFile "c:\misdocumentos\*\R1???97.xls", "c:\temp"