title: Invalid Variant Operation using MS Word OLE Automation only on one specific machine
body: <p>I am doing some search replace work using OLE Automation. The involved code is somehow the same I posted in <a href="https://stackoverflow.com/questions/9520261/improve-performance-of-search-replace-in-word-document-using-ole-and-delphi">This question</a>.</p>
  
  <p>On only one machine I have an "Invalid Variant Operation" error. This error appeared just after upgrading from MSOffice 2003 to 2010. But this occurs only on one pc, i tested on several pcs with office 2010 and the code works great.</p>
  
  <p>I am really stuck, I tried to build with Eureka log And I will paste the call stack at the end of this question.</p>
  
  <p>I hope somebody already stumbled into this problem so you can suggest.</p>
  
  <p>The problem occured at a customer end, there are 100 machines connected to same DB and only on one it doesn't work.</p>
  
  <pre><code>Call Stack Information:
  --------------------------------------------------------------------------------------------------
  |Address |Module           |Unit        |Class           |Procedure/Method             |Line     |
  --------------------------------------------------------------------------------------------------
  |*Exception Thread: ID=776; Priority=0; Class=; [Main]                                           |
  |------------------------------------------------------------------------------------------------|
  |0043554F|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |00435520|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |00435CAA|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |770F48F0|oleaut32.dll     |            |                |VariantClear                 |         |
  |00435B43|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |0043590C|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |00435B48|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |00435BE4|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |00407316|Project1.exe|System.pas  |                |_HandleFinally               |14330[39]|
  |00407460|Project1.exe|System.pas  |                |_RaiseExcept                 |14712[1] |
  |00635EED|Project1.exe|ComObj.pas  |                |DispCallError                |2024[13] |
  |004070DA|Project1.exe|System.pas  |                |_HandleAnyException          |13728[81]|
  |77E256A3|RPCRT4.dll       |            |                |NdrClientCall2               |         |
  |7C80A174|kernel32.dll     |            |                |WideCharToMultiByte          |         |
  |0040C4DB|Project1.exe|System.pas  |                |LocaleCharsFromUnicode       |29632[1] |
  |0040C4C0|Project1.exe|System.pas  |                |LocaleCharsFromUnicode       |29631[0] |
  |00407EFC|Project1.exe|System.pas  |                |CharFromWChar                |17375[3] |
  |00407EDC|Project1.exe|System.pas  |                |CharFromWChar                |17372[0] |
  |00407F17|Project1.exe|System.pas  |                |CharFromWChar                |17381[1] |
  |00407F08|Project1.exe|System.pas  |                |CharFromWChar                |17380[0] |
  |004090CE|Project1.exe|System.pas  |                |_UStrToString                |22054[8] |
  |00404DA4|Project1.exe|System.pas  |                |Move                         |4808[1]  |
  |004090ED|Project1.exe|System.pas  |                |_UStrToString                |22061[15]|
  |7C920380|ntdll.dll        |            |                |RtlImageNtHeader             |         |
  |00407460|Project1.exe|System.pas  |                |_RaiseExcept                 |14712[1] |
  |00635EED|Project1.exe|ComObj.pas  |                |DispCallError                |2024[13] |
  |004070DA|Project1.exe|System.pas  |                |_HandleAnyException          |13728[81]|
  |00407460|Project1.exe|System.pas  |                |_RaiseExcept                 |14712[1] |
  |00635EED|Project1.exe|ComObj.pas  |                |DispCallError                |2024[13] |
  |7C913247|ntdll.dll        |            |                |RtlConvertUlongToLargeInteger|         |
  |00404A95|Project1.exe|System.pas  |                |_ReallocMem                  |3871[22] |
  |00404A88|Project1.exe|System.pas  |                |_ReallocMem                  |3850[1]  |
  |00409130|Project1.exe|System.pas  |                |_UStrSetLength               |22152[27]|
  |00408198|Project1.exe|System.pas  |                |_UStrAsg                     |17715[1] |
  |0040C3EF|Project1.exe|System.pas  |                |UTF8ToUnicodeString          |28576[11]|
  |00407DB8|Project1.exe|System.pas  |                |_UStrClr                     |16954[1] |
  |0040C404|Project1.exe|System.pas  |                |UTF8ToUnicodeString          |28577[12]|
  |7C91E485|ntdll.dll        |            |                |KiUserApcDispatcher          |         |
  |7C912B04|ntdll.dll        |            |                |RtlInterlockedPushListSList  |         |
  |77E943DB|SHLWAPI.dll      |            |                |SHRegGetValueW               |         |
  |77E943E8|SHLWAPI.dll      |            |                |SHRegGetValueW               |         |
  |00407460|Project1.exe|System.pas  |                |_RaiseExcept                 |14712[1] |
  |00635EED|Project1.exe|ComObj.pas  |                |DispCallError                |2024[13] |
  |00635E48|Project1.exe|ComObj.pas  |                |DispCallError                |2011[0]  |
  |00635F20|Project1.exe|ComObj.pas  |                |DispatchInvokeError          |2031[1]  |
  |00635F1C|Project1.exe|ComObj.pas  |                |DispatchInvokeError          |2031[1]  |
  |00635BF9|Project1.exe|ComObj.pas  |                |DispatchInvoke               |1895[108]|
  |00635940|Project1.exe|ComObj.pas  |                |DispatchInvoke               |1787[0]  |
  |00635E3B|Project1.exe|ComObj.pas  |                |VarDispInvoke                |2002[10] |
  |774CF17D|ole32.dll        |            |                |CoCreateInstanceEx           |         |
  |77E25AE5|RPCRT4.dll       |            |                |IUnknown_Release_Proxy       |         |
  |00435C7A|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |00435BE4|Project1.exe|SysUtils.pas|                |DoneExceptions               |17031[25]|
  |004627DF|Project1.exe|Classes.pas |TThread         |Create                       |11471[28]|
  |004627D0|Project1.exe|Classes.pas |TThread         |Create                       |11471[28]|
  |00501FE5|Project1.exe|ActnList.pas|TContainedAction|Execute                      |448[8]   |
  |00501FB4|Project1.exe|ActnList.pas|TContainedAction|Execute                      |440[0]   |
  |00502DA0|Project1.exe|ActnList.pas|TCustomAction   |Execute                      |1094[7]  |
  |00406498|Project1.exe|System.pas  |                |_CallDynaInst                |11592[1] |
  |004626A3|Project1.exe|Classes.pas |TThread         |Create                       |11471[28]|
  |00532DA4|Project1.exe|Menus.pas   |TMenuItem       |Click                        |2525[17] |
  </code></pre>