title: Can't write to zip File if using a string or variant in Shell.Application Copyhere
body: <p>I am having troubles with NameSpace CopyHere function. I am trying to create a zip file containing a bunch of logs. I can create the zip file just fine, but when using the NameSpace.CopyHere, if I use a string or a variant containing a string, it won't write the file to the zip archive.</p>
  
  <p>For example, I have a file located at P:\test2.txt .</p>
  
  <p>If I use those lines :</p>
  
  <pre><code> objApp.Namespace(sZipArchive).CopyHere sFile
   objApp.Namespace(sZipArchive).CopyHere vLogs(i)
  </code></pre>
  
  <p>where sFile = vLogs(i) = "P:\test2.txt</p>
  
  <p>the file test2.txt won't be copied in the zip archive.</p>
  
  <p>However, if I use this line :</p>
  
  <pre><code>objApp.Namespace(sZipArchive).CopyHere "P:\test2.txt"
  </code></pre>
  
  <p>Then, the file gets copied in the zip file. </p>
  
  <p>If I put a check to see if the sFile or vLog(i) is = "P:\test2.txt", I can see that they are the same thing. </p>
  
  <p>Is there something I am missing here on why the first 2 lines don't work, but the third one does?</p>
  
  <p>Thank you for your time.</p>
  
  <p>Full sub :</p>
  
  <pre><code>Private Sub BtnSaveToZip_Click()
  Dim bEndRow, bTest As Boolean
  Dim iRow, iCount As Integer
  Dim sZipArchive, sDate, sFolderExists, sFile As String
  Dim vLogs, vFilename As Variant
  Dim objApp As Object
  
  sDate = Date
  sDate = Replace(sDate, "/", "") ' set date format to DDMMYYYY instead of DD/MM/YYYY
  sZipArchive = LblLogArchive + "\" + sDate
  sFolderExists = Dir(sZipArchive)
  If sFolderExists = "" Then
      CreateDir (sZipArchive) ' if the subfolder with the date does not exists, create it
  End If
  sZipArchive = sZipArchive + "\" + wsContacts.Range("B7").Value + " Logs_" + sDate + ".zip"
  'Check if file is open
  If FileLocked(sZipArchive) Then
      MsgBox sZipArchive + " already open. Please close the archive."
      Exit Sub
  End If
  
  'Creating the zip file from Ron de Bruin
  NewZip (sZipArchive)
  
  'filling the zip file
  Set objApp = CreateObject("Shell.Application")
  
  bEndRow = False
  iRow = gFirstData
  Do While bEndRow = False
      If Not IsEmpty(wsLogs.Cells(iRow, gTestCase).Value) Then
          If Not IsEmpty(wsLogs.Cells(iRow, gLog).Value) Then
              vLogs = Split(wsLogs.Cells(iRow, gLog).Value, ";")
              For i = 0 To UBound(vLogs) - 1
                  sFile = vLogs(i) ' Debug only
                  If sFile = "P:\test2.txt" Then 'Debug only
                  objApp.Namespace(sZipArchive).CopyHere vLogs(i) ' if I put "P:\test2.txt", it works correctly
                  'Keep script waiting 5s for debug purpose
                  Application.Wait (Now + TimeValue("00:00:05"))
                  End If
              Next
          End If
      iRow = iRow + 1
      Else
          bEndRow = True
      End If
  Loop
  MsgBox "Zip successfully created"
  Set objApp = Nothing
  End Sub    
  </code></pre>