title: VB6 Missing DLL error when passing Excel object to function on some machines but works if not passed. why?
body: <p>I can't figure out why some users (but not all) are seeing errors if I pass Excel to another function or sub with VB6. </p>
  
  <p>This fails for some but not all. They get missing DLL or interface not registered error. </p>
  
  <pre><code>sub test()
  Dim xl As Object, xlwbook As Object, xlsheet As Object
  Set xl = CreateObject("excel.application")
  Set xlwbook = xl.Workbooks.Add(xlWBATWorksheet)
  xlwbook.Sheets("Sheet1").Name = "REPORT"
  Set xlsheet = xlwbook.Sheets("REPORT") 
  
  Call formatlogo(xlsheet)
  End Sub
  
  function formatlogo(xlsheet As Worksheet)
  xlsheet.Cells(1, 1).Characters(1, 1).Font.Name = "Webdings"
  end function
  </code></pre>
  
  <p>This works for everyone.</p>
  
  <pre><code>sub test()
  Dim xl As Object, xlwbook As Object, xlsheet As Object
  Set xl = CreateObject("excel.application")
  Set xlwbook = xl.Workbooks.Add(xlWBATWorksheet)
  xlwbook.Sheets("Sheet1").Name = "REPORT"
  Set xlsheet = xlwbook.Sheets("REPORT") 
  
  xlsheet.Cells(1, 1).Characters(1, 1).Font.Name = "Webdings"
  End Sub
  </code></pre>
  
  <p>Why can't I pass an Excel object without dll errors for some folks?
  Thank you in advance. </p>