0

i can't get the progress windows with copyFile

Working example:

Sub File()

Dim FSO As Object
Dim foi As Object
Dim fo As Object
Dim fi As Object
Dim testfs As String
Dim FileIO
Set FSO = CreateObject("Scripting.FileSystemObject")


'Set FSO = CreateObject("Scripting.FileSystemObject")
'Set FileSystem = CreateObject("Scripting.FileSystemObject")


Set fo = FSO.GetFolder("C:\Users\Peer\Desktop\Cache\vba\NeuerOrdner\") 

For Each foi In fo.Files 
  Debug.Print foi.Name
  testfs = foi.Name
Next foi

Set fi = FSO.GetFile(fo.Path & "\" & testfs) 

'working copy
FSO.CopyFile fi.Path, fi.ParentFolder.Path & "\NeuerOrdner\", True

End Sub

This results in an error

'Error: Object required (Error 424)
FSO.CopyFile fi.Path, fi.ParentFolder.Path & "\NeuerOrdner\", FileIO.UIOption.AllDialogs

Additionally i cant use brackets like in the example, and i'm not sure why

'Compile Error: Expected: =
FSO.CopyFile(fi.Path, fi.ParentFolder.Path & "\NeuerOrdner\", True)

i have the Solution from here: How to bring up the built-in File Copy dialog?

protter
  • 119
  • 7
  • The linked solution is for VB.NET where this one is VBA. They are not the same. – Kostas K. Nov 15 '21 at 14:45
  • So the only ay is something like this?: https://stackoverflow.com/questions/14227172/copy-files-with-progress-bar – protter Nov 15 '21 at 14:59
  • Yes, that's appropriate solution for VBA to display the progress dialog. It also retains the file attributes (readonly etc) if any. – Kostas K. Nov 15 '21 at 15:03

0 Answers0