Determine office version

K

Kjell

Hi

Is there a way to determine the installed office version??
(or at least the installed MS-Excel version) ??

Like an API call, or reading a registry key ??

Thanks

Kjell
 
K

Karl E. Peterson

Kjell said:
Is there a way to determine the installed office version??
(or at least the installed MS-Excel version) ??

Easiest way would be to query the Application.Version property, presumably? Of
course, that's also the most time expensive.
Like an API call, or reading a registry key ??

No API calls. You could _try_ interpreting the registry, but it's kinda messy. You
can start enumerating under HKLM\Software\Microsoft\Office, looking for a key named
"8.0", "9.0", "10.0", or [...] that has a subkey named "Excel".
 
K

Kjell

I've looked at the registry keys "8.0", "9.0" and "10.0", but it's not making
any sence to me, On my own machine I have Office2003 (moving from Office2000
a year ago)

Office2003 is version 9.0 ? (I assume), so why is "10.0" listed in
registry ?

So, how do I interpret the available keys?


2nd question

can you tell me more on the "query the Application.Version property"
where can find more details........ aso....


Kjell


Karl E. Peterson said:
Kjell said:
Is there a way to determine the installed office version??
(or at least the installed MS-Excel version) ??

Easiest way would be to query the Application.Version property, presumably? Of
course, that's also the most time expensive.
Like an API call, or reading a registry key ??

No API calls. You could _try_ interpreting the registry, but it's kinda messy. You
can start enumerating under HKLM\Software\Microsoft\Office, looking for a key named
"8.0", "9.0", "10.0", or [...] that has a subkey named "Excel".
 
J

Jonathan West

Hi Kjell

Take a look here

Determine If Word is Installed
http://vb.mvps.org/articles/qa200206.asp

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Kjell said:
I've looked at the registry keys "8.0", "9.0" and "10.0", but it's not
making
any sence to me, On my own machine I have Office2003 (moving from
Office2000
a year ago)

Office2003 is version 9.0 ? (I assume), so why is "10.0" listed in
registry ?

So, how do I interpret the available keys?


2nd question

can you tell me more on the "query the Application.Version property"
where can find more details........ aso....


Kjell


Karl E. Peterson said:
Kjell said:
Is there a way to determine the installed office version??
(or at least the installed MS-Excel version) ??

Easiest way would be to query the Application.Version property,
presumably? Of
course, that's also the most time expensive.
Like an API call, or reading a registry key ??

No API calls. You could _try_ interpreting the registry, but it's kinda
messy. You
can start enumerating under HKLM\Software\Microsoft\Office, looking for a
key named
"8.0", "9.0", "10.0", or [...] that has a subkey named "Excel".
 
K

Kjell

This is embarrissing :-( I've been working with VB for many years and done
alot of VBA applications, I should know this.

Many thanks Jonathan, and to Karl for doing the article in the first place.

Kjell

Jonathan West said:
Hi Kjell

Take a look here

Determine If Word is Installed
http://vb.mvps.org/articles/qa200206.asp

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Kjell said:
I've looked at the registry keys "8.0", "9.0" and "10.0", but it's not
making
any sence to me, On my own machine I have Office2003 (moving from
Office2000
a year ago)

Office2003 is version 9.0 ? (I assume), so why is "10.0" listed in
registry ?

So, how do I interpret the available keys?


2nd question

can you tell me more on the "query the Application.Version property"
where can find more details........ aso....


Kjell


Karl E. Peterson said:
Kjell wrote:
Is there a way to determine the installed office version??
(or at least the installed MS-Excel version) ??

Easiest way would be to query the Application.Version property,
presumably? Of
course, that's also the most time expensive.

Like an API call, or reading a registry key ??

No API calls. You could _try_ interpreting the registry, but it's kinda
messy. You
can start enumerating under HKLM\Software\Microsoft\Office, looking for a
key named
"8.0", "9.0", "10.0", or [...] that has a subkey named "Excel".
 
J

Jonathan West

Kjell said:
This is embarrissing :-( I've been working with VB for many years and
done
alot of VBA applications, I should know this.

Many thanks Jonathan, and to Karl for doing the article in the first
place.

Kjell

Karl should be even more embarrassed - in his answer, he forgot to point you
to his own article! :)


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
K

Kjell

It works fine..... with one exception....

obj.build property reports incorrect value, I think it's due to installed
service packs
Do you know if it's possible to figure out the installed service pack and
through that get correct build number ?

I find it a bit strange that MS hasn't created API calls for this long time
ago, not all companies can afford big smart solution to maintain their
licensing obligations.

Kjell
 
K

Kjell

I am, but in order to get the picture complete I would like to know if a
service pack is intalled or not.

My Excel reports a higher build number than the obj.build function suggested
by Karl, so I think this comes from an installed service pack, I have SP3
installed.

Is there a way to detect an installed service pack? (for office)

Kjell
 
J

Jonathan West

The only way is to look at the build number. but its not just Service packs
that my change the build. Hotfixes & other updates may also.

You can go to http://support.microsoft.com/dllhelp/ and look up version
numbers for various prodcts. I'm not sure how complete & up-to-date
Microsoft keeps that page, but I don't know of a better resource.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
K

Karl E. Peterson

Kjell said:
I am, but in order to get the picture complete I would like to know
if a service pack is intalled or not.

My Excel reports a higher build number than the obj.build function
suggested by Karl, so I think this comes from an installed service
pack, I have SP3 installed.

Is there a way to detect an installed service pack? (for office)

Looks like Jonathan pointed you toward a good lookup table, once you have the actual
file version info. Here's how (on reflection) I might suggest you get at that, given
the confusion (and overhead!) with Automation.

First, find the actual Excel.exe file (you may need to create a temporary file, with
the proper extension, if you don't have an existing one handy):

Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA"
(ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As
Long

Private Const MAX_PATH As Long = 260

Public Function FindDocAssociation(ByVal FileName As String) As String
Dim Buffer As String
Dim nRet As Long
' Prepare buffer, and query operating system.
Buffer = Space$(MAX_PATH)
nRet = FindExecutable(FileName, vbNullString, Buffer)
If nRet < 0 Or nRet > 32 Then 'account for potential negative instance handles
' Return results. If an executable was passed as input,
' this will be identical. Must be actual document file.
FindDocAssociation = Left$(Buffer, InStr(Buffer, vbNullChar) - 1)
End If
End Function

Now, use CFileVersionInfo from http://vb.mvps.org/samples/FileInfo to obtain the
actual version information from the currently associated executable. This will be
nearly instantaneous, in comparison to creating an Application object and querying
its properties.

Later... Karl
 
S

Steve Rindsberg

Sweet ... but to clarify one thing:
First, find the actual Excel.exe file (you may need to create a temporary file, with
the proper extension, if you don't have an existing one handy):

IOW, create a dummy file with an .XLS (or .DOC or .PPT or whatever) extension then pass
that to FindExecutableA as lpFile, if I understand correctly.

And it occurs to me that you might want to filter the results a bit before proceeding.
ISTR that absent Word, DOC files are associated with WordPad. There might be other
loopy things that screw this up. PPT associated to the PPT viewer rather than
PowerPoint, PPT associated to a stub EXE in Office versions that don't include
PowerPoint, etc.
 
K

Karl E. Peterson

Hi Steve --
Sweet ... but to clarify one thing:


IOW, create a dummy file with an .XLS (or .DOC or .PPT or whatever)
extension then pass that to FindExecutableA as lpFile, if I
understand correctly.

Yep! That's the idea. To be _really_ clean about it, you'd want to find the user's
temp folder, and create it there. Then, of course, kill it afterwards.
And it occurs to me that you might want to filter the results a bit
before proceeding. ISTR that absent Word, DOC files are associated
with WordPad. There might be other loopy things that screw this up.
PPT associated to the PPT viewer rather than PowerPoint, PPT
associated to a stub EXE in Office versions that don't include
PowerPoint, etc.

Good point! It's certainly possible, I would suppose, that other (OpenOffice?) apps
might be used for those associations, as well. Always good to do the "sniff test" on
this sort of thing.

Thanks... Karl
--
Working Without a .NET?
http://classicvb.org/petition

 
T

TC

Gak! Start a whole new copy of Word, just to see if it is installed?

Use HKCR/Word.Application/CurrentVersion, or whatever it is. Kills two
birds with one stone (is it installed? what is its version?) and does
not need to start a copy.

HTH,
TC
 
K

Kjell

"He who seeks, he will find" :)

I found this article on MSDN
http://support.microsoft.com/default.aspx?scid=kb;en-us;255275

It's the mso9.dll that gives the correct version string for the office
installation
so that the service pack level can be interpreted.

This covers at least everyting I need for covering Office2000
I assume Office2003 will have a similar way once the service packs are being
released

Kjell Liljegren


Karl E. Peterson said:
Kjell said:
Is there a way to determine the installed office version??
(or at least the installed MS-Excel version) ??

Easiest way would be to query the Application.Version property, presumably? Of
course, that's also the most time expensive.
Like an API call, or reading a registry key ??

No API calls. You could _try_ interpreting the registry, but it's kinda messy. You
can start enumerating under HKLM\Software\Microsoft\Office, looking for a key named
"8.0", "9.0", "10.0", or [...] that has a subkey named "Excel".
 
S

Steve Rindsberg

This covers at least everyting I need for covering Office2000
I assume Office2003 will have a similar way once the service packs are being
released

SP1's been out for quite some time and SP2 was released around 1 October.
 
K

Kjell

After some more searching I found in total over 20 articles handling the
subject, incl Office 2000, OfficeXP and Office2003

Many of them indicating that also MS realised the problem with determine
version and service pack level.

The total number of combinations with Versions, SP's, Patches, builds and
Executables are MANY (maybe hundreds) :)

here is one for OfficeXP
http://support.microsoft.com/kb/291331/
and one for Office2003
http://support.microsoft.com/kb/821549/


Kjell
 
S

Steve Rindsberg

After some more searching I found in total over 20 articles handling the
subject, incl Office 2000, OfficeXP and Office2003

Many of them indicating that also MS realised the problem with determine
version and service pack level.

Yep. Apparently they can't even get it right. What's shown for PowerPoint 2003
SP3 on the page you cite (and thanks for those, by the way) doesn't agree with the
two installations I have here, both of which show 11.6564.6568

sigh
 
K

Karl E. Peterson

TC said:
Gak! Start a whole new copy of Word, just to see if it is installed?

Use HKCR/Word.Application/CurrentVersion, or whatever it is. Kills two
birds with one stone (is it installed? what is its version?) and does
not need to start a copy.

That's a good way to deterimine if Word _was_ installed. Does it really tell you if
it _is_ installed, though? Is "Probably, but..." good enough?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top