The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Email Subscription

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 716 other subscribers

How Can I Determine Which Version of Word is Installed on a Computer? – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs

Posted by jpluimers on 2014/07/24

Late binding sometimes is your friend:

Set objWord = CreateObject("Word.Application")
Wscript.Echo "Version: " & objWord.Version
Wscript.Echo "Build: " & objWord.Build
objWord.Quit

The accompanying Delphi code:

[sourcecode language=”pascal”]
uses
System.Win.ComObj;

procedure TTestVersionAgnosticWordMainForm.GetWordApplicationInfoButtonClick(Sender: TObject);
var
WordApplication: OleVariant;
Version: OleVariant;
Build: OleVariant;
begin
WordApplication := CreateOleObject(‘Word.Application’);
try
try
Version := WordApplication.Version;
Build := WordApplication.Build;
LogMemo.Lines.Add(Version);
LogMemo.Lines.Add(Build);
finally
WordApplication.Quit;
end;
finally
WordApplication := Unassigned; // release it
end;
end;
[/sourcecode]

–jeroen

via: How Can I Determine Which Version of Word is Installed on a Computer? – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs.

10 Responses to “How Can I Determine Which Version of Word is Installed on a Computer? – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs”

  1. Bernd's avatar

    Bernd said

    Other option: query windows installer with upgrade code of office. then query the components with the component codes.

  2. Thomas's avatar

    Thomas said

    Btw. the same code is possible with early binding.
    And Bernd has a good Argument.

  3. Bernd's avatar

    Bernd said

    I think this solution isn’t good. the reason is simple. if word is installed as “install on demand” / “advertised” it will be installed when “Word.Application” is created. Many installations are broken or required the DVD. Better solution check in registry that “Word.Application” and get the executable which contains the com-server. Get the version from that executable.

    • jpluimers's avatar

      jpluimers said

      Yes, my method is not exactly friendly to broken installations. It forces them to fix their installation, which – to me – is good.

Leave a Comment

 

Discover more from The Wiert Corner - irregular stream of stuff

Subscribe now to keep reading and get access to the full archive.

Continue reading