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:
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;
–jeroen
Bernd said
Other option: query windows installer with upgrade code of office. then query the components with the component codes.
jpluimers said
How would I do that?
quantendreher said
Easy: Get the upgrade code from the office setup by using orca (Table property). Use MsiEnumRelatedProducts with the upgrade code. http://msdn.microsoft.com/en-us/library/aa370103
The result guid’s are used with MsiGetProductInfo the get required informations. http://msdn.microsoft.com/en-us/library/aa370130
jpluimers said
Now someone please add those API wrappers somewhere, and the const values for the respective products (:
quantendreher said
API are in JEDI Code Lib. – jwaMSI.pas and a other file. can’t remember it’s name.
jpluimers said
Thanks.
Thomas said
Btw. the same code is possible with early binding.
And Bernd has a good Argument.
jpluimers said
Early binding highly depends on your Delphi version and which Office units you choose during installation.
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 said
Yes, my method is not exactly friendly to broken installations. It forces them to fix their installation, which – to me – is good.