title: VBA Calling C++ DLL - error 48 (file not found)
body: <p>I have an Excel workbook that calls a test DLL I wrote in C++.  The path to DLL is hardcoded in VBA.  The only files the DLL uses are stdlib and iostream.</p>
  
  <p>On my machine it works.  On several other office machines it works.  However, on the remainder when i try to call the DLL through Excel I get error 48 - file not found. </p>
  
  <p>My understanding is error 53 is the file is missing; error 48 is there are missing dependencies.  I have used dependency walker and have not found any issues. </p>
  
  <p>What I did discover, however, is that if I install Visual Studio on a machine there is a 90% chance that after the install the Excel file/DLL works perfectly.  On the 10% that it does not work, I restart and re-run the Visual Studio install, selected 'repair', and after the installation finishes again the Excel/DLL combo works.  So basically installing Visual Studio allows the DLL to be loaded by Excel.  If i uninstall Visual Studio the DLL still works fine. </p>
  
  <p>Obviously this means something is missing on those machines, but I have no idea what - I've tried separately installing all the pieces that show up under 'programs', such as most current .net framework, visual c++ re-distributables, etc... and it doesn't work.  The only thing that works is installing Visual Studio itself. 
  I'm not certain how to proceed since asking users to mount a 5gig ISO and install a developer environment isn't really ideal.</p>
  
  <hr>
  
  <p>Ah-ha, I found the issue. It turns out that it requires 2 DLL files - msvcr120.dll and msvc120.dll. I had these 2 files in my System32 folder, but not in my SysWOW64 folder. As soon as i populated that folder then the DLLs started working.</p>
  
  <p>I found many threads on google with the 'same' problem but no answer, so if you run into the same issue I'd suggest using dependency walker and making sure the DLLs are in both system folders to be safe (although I suspect System32 is only needed for 64bit DLL, and SysWOW64 for 32bit DLLs).</p>