lundi 26 avril 2021

if/else statement with "contains" argument in file path/type vba

The issue here is that I'm trying to avoid copying files that are ".doc" but it seems to be copying them, and I'm not sure if this is the right way for a contains argument. What I want to do is "If file contains/is a word doc, then ommit and go to next file.

Dim FSO as FileSystemObject

Dim MYFSO = New Filesytemobject
Dim MyFile as File 
Dim MyFolder as Folder

Dim copyfolder as Folder
Dim Sourcefolder As string
Dim Destinationfolder as String 

Sourcefolder = "C:\TestA" 
DestinationFolder = "C:\TestB" 

Set myfolder = myfso.getfolder(sourcefolder) 

For each myfile in myfolder.files 
if myfso.getextensionname(myfiles) = ".word" Then 
else myfso.copyfolder myfolder, destinationfolder 
 end if 
 on error resume next 
next myfile 

end sub

Aucun commentaire:

Enregistrer un commentaire