title: Copy file to compressed folder
body: <p>I'm trying to copy an existing file to an existing compressed folder without any 3rd party tools.</p>
  
  <p>I tried two different ways but none were successful. I use a text file for my examples, in reality I need to copy an Excel File to an existing compressed folder in a shared drive. </p>
  
  <p>1st Way (<code>FileSystemObject</code>):</p>
  
  <pre><code>Call MoveToZip()
  
  Function MoveToZip()
      Dim FromPath, ToPath, ObjFSO
  
      FromPath = "C:\Users\User\Desktop\New_Folder\TestFile.txt"
      ToPath = "C:\Users\User\Desktop\NewCompressed.zip"
  
      Set ObjFSO = CreateObject("Scripting.FileSystemObject")
  
      ObjFSO.CopyFile FromPath, ToPath
  End Function
  </code></pre>
  
  <p>2nd Way (<code>Shell</code>):</p>
  
  <pre><code>Call fnMoveToZip()
  
  Function fnMoveToZip()
      Dim objShell
      Dim objFolder
  
      Set objShell = CreateObject("shell.Application")
      Set objFolder = objShell.NameSpace("C:\Users\User\Desktop\NewCompressed.zip")
  
      objFolder.CopyHere("C:\Users\User\Desktop\New_Folder\TestFile.txt")
  
  
      Set objShell = nothing
      Set objFolder = nothing
  End Function
  </code></pre>