title: Deleting a file immediately after closing it - 'Permission Denied' error
body: <p>I want to save an email as a Word file through a macro, and then replace this with a converted PDF file via Word. The conversion part is working fine - the issue is when I try to delete the original .doc file.</p>
  
  <pre><code>Dim objWrd As Object
  Dim objWrdDoc As Object
  Dim wrdCurrentPrinter As String
  
  Set objWrd = CreateObject("Word.Application")
  Set objWrdDoc = objWrd.Documents.Open(filePath &amp; fileName)
  
  ''Print' file as PDF - current printer is stored so it can be reverted back afterwards
  wrdCurrentPrinter = objWrd.ActivePrinter
  objWrd.ActivePrinter = "Microsoft Print To PDF"
  
  'File name is specified here to avoid Save As prompt. PrintToFile property is 'True'
  objWrd.PrintOut , , , filePath &amp; Replace(fileName, ".doc", ".pdf"), , , , , , , True
  
  objWrd.ActivePrinter = wrdCurrentPrinter
  
  objWrd.Quit
  Set objWrd = Nothing
  
  Kill filePath &amp; fileName
  </code></pre>
  
  <p>At <code>Kill filePath &amp; fileName</code> I get error 70 - Permission denied.</p>
  
  <p>I am able to delete the file manually without any problems, and if I add a breakpoint and step through the 'Kill' line, it works when there is even a slight delay between Word closing and the Kill command. Therefore I suspect that the code is being processed so quickly so that the file is still open at the time of running the command.</p>
  
  <p>I have a feeling I may need to go down the route of creating a delay, which I have been having trouble with in Outlook. Is this the likely solution or is there something else that I have missed?</p>