UnDiUdin
UnDiUdin

Reputation: 15374

Machine dependent results for OLE check of MSWord version

With this code to retrieve the version of the installed MS Word:

uses uses oleauto;

[...]

function TForm2.GetWordVersion:string;
const
  wdDoNotSaveChanges = 0;
var
  WordApp: OLEVariant;
  WordVersion: variant;
begin
  Try
      WordApp := CreateOLEObject('Word.Application');
      WordVersion := WordApp.version;
      WordApp.Quit(wdDoNotSaveChanges);
  except
    on E: Exception do
    begin
      WordVersion := -1;
    end;

  End;
  Result :=  wordversion;
end;

I get 140 on my machine, my colleague gets 14. Both are win7/Word2010 but I am in Italy he is in India.

Anyone knows about this?

Why different values?

Thanks

Upvotes: 0

Views: 222

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

I'm guessing this is a decimal separator issue. Word returns the string '14.0' and then when you convert to integer the period is treated as a positional separator on one machine, and a decimal separator on another.

The solution is to stop converting to integer which I infer that you are doing in code that you have not shown.

I am inferring that from this comment:

I can convert it to string and use the first 2 chars.

Since the code in the question operates on strings, I conclude that other code, not shown in the question, is converting to integer.

Upvotes: 2

Related Questions