| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

10-01-05, 05:03
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
|
get office version in A-VBA
|
|
i'm looking for a bullet-proof method that runs in Access code under Offices 2k, 2k3, XP that allows the client to determine which office version it is running.
thanks for any suggestions.
izy
__________________
currently using SS 2008R2
|
|

10-01-05, 06:46
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Access.Version or SysCmd(acSysCmdAccessVer) will return the version number, i.e.
8 = Access 97
9 = Access 2000
10 = Access 2002/XP
11 = Access 2003
Access.Version only works in Access2000+, so SysCmd(acSysCmdAccessVer) is better.
If you need the build number you can get it with SysCmd(715) in Access 2000+
e.g
Code:
?Choose(SysCmd(acSysCmdAccessVer)-7,"Access 97", "Access 2000","Access 2002/XP", "Access 2003")
|
Last edited by waynephillips; 10-01-05 at 06:54.
|

10-01-05, 09:18
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
|
|
thanks Wayne, that works fine for Access version...
sorry, there is a "but"
...but i need to determine Office version (and Excel and Outlook version which i forgot to mention in the earlier post)
e.g. my XP box runs Office-XP except for Access which is 2k-dev.
acSysCmdAccessVer will happily tell me 9.0 but that doesn't help me with the appropriate Outlook/Excel/Office libraries that i need to reference from code.
my current scam is too primitive - imagehlp/SearchTreeForFile one by one on all 9 libraries x revisions to see what's available on the client.
izy
LATER: 12 libraries x revisions if i account for all of them, tho i only have 2k, 2k3, and a few XP out there with my users.
__________________
currently using SS 2008R2
|
Last edited by izyrider; 10-01-05 at 09:21.
|

10-01-05, 09:23
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Quote:
|
Originally Posted by izyrider
thanks Wayne, that works fine for Access version...
sorry, there is a "but"
...but i need to determine Office version (and Excel and Outlook version which i forgot to mention in the earlier post)
e.g. my XP box runs Office-XP except for Access which is 2k-dev.
acSysCmdAccessVer will happily tell me 9.0 but that doesn't help me with the appropriate Outlook/Excel/Office libraries that i need to reference from code.
my current scam is too primitive - imagehlp/SearchTreeForFile one by one on all 9 libraries x revisions to see what's available on the client.
izy
|
Ok, well what you're asking for is ambiguous. Access as we all know is part of the office suite AND can be installed seperately just like *all* the office products. For example, a user could have Access 97, Outlook 2000 and Excel 2003 - which version of "Office" do they have? well parts of all three technically...
Therefore you really do need to treat each as a seperate program to be 100% sure.
|
|

10-01-05, 09:33
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Consider using late binding to determine each version:
Code:
Set objApp = CreateObject("Access.Application") ' Don't specify version
lngAccessVersion = CLng(objApp.Version)
objApp.Quit
Set objApp = Nothing
Set objApp = CreateObject("Excel.Application") ' Don't specify version
lngExcelVersion = CLng(objApp.Version)
objApp.Quit
Set objApp = Nothing
Set objApp = CreateObject("Outlook.Application") ' Don't specify version
lngOutlookVersion = CLng(Left(objApp.Version, InStr(1, objApp.Version, ".") - 1))
objApp.Quit
Set objApp = Nothing
Then you can use this info for setting up the references. note: Outlook seems to return the build number in the string that is returned by objApp.Version so I've just trimmed it off above.
If you don't want to do late binding you are going to have to search the registry, like you said.
|
|

10-01-05, 09:41
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
thanks Wayne
...experimenting now.
BTW, imagehlp/SearchTreeForFile is scanning the entire c:\ for the library files - which is why i don't want to do it 9 (...12 times)... takes forever!
your registry idea is interesting: search one file instead of a potentially humungous disk. might also assist if there is some truly obscure setup with libraries elsewhere than on c:\
can you illustrate or point to a registry method?
izy
__________________
currently using SS 2008R2
|
|

10-01-05, 09:44
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
...oooops, forgot: i also need the underlying Office library for menu manipulation. any suggestions for that in your late-bind scheme?
izy
__________________
currently using SS 2008R2
|
|

10-01-05, 09:50
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Quote:
|
Originally Posted by izyrider
thanks Wayne
...experimenting now.
BTW, imagehlp/SearchTreeForFile is scanning the entire c:\ for the library files - which is why i don't want to do it 9 (...12 times)... takes forever!
your registry idea is interesting: search one file instead of a potentially humungous disk. might also assist if there is some truly obscure setup with libraries elsewhere than on c:\
can you illustrate or point to a registry method?
izy
|
Oh right, I didn't realise - I've never used that library before. If you were to use the file search method it would be better to use the Scripting Runtime and recursively search each directory. That way you only search the drive once. Anyway, like you said that is a bad idea in reality.
The registry keys would be
HKEY_CLASSES_ROOT/Access.Application/CurVer/
HKEY_CLASSES_ROOT/Outlook.Application/CurVer/
HKEY_CLASSES_ROOT/Excel.Application/CurVer/
The default string value in these indicates the version of the application that was
last opened on the machine. e.g. a string of 'Access.Application.11' or 'Access.Application.10'
I don't think there is an ActiveX wrapper for reading the registry, so you would need to use the Win API direcly. Have a search on MSDN for reading registry keys. RegOpenKey() etc - If you need more help with reading the registry I can do later when I have more time, unless someone else wants to help you 
|
|

10-01-05, 09:51
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Quote:
|
Originally Posted by izyrider
...oooops, forgot: i also need the underlying Office library for menu manipulation. any suggestions for that in your late-bind scheme?
izy
|
Hmm what do you mean by menu manipulation? Why is this office-version specific?
|
|

10-01-05, 10:01
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
so, correct me if i'm wrong, but i thought i needed the Office library to disappear command bars.
meanwhile, my late-bind experiments hit a brick wall
Code:
Private Sub uriGetVersion(versACC As Long, versXLS As Long, versOUT As Long)
Dim objApp As Application 'or object or nothing at all
Set objApp = CreateObject("Access.Application") ' Don't specify version
versACC = CLng(objApp.Version)
objApp.Quit
Set objApp = Nothing
Set objApp = CreateObject("Excel.Application") ' Don't specify version
versXLS = CLng(objApp.Version)
objApp.Quit
Set objApp = Nothing
Set objApp = CreateObject("Outlook.Application") ' Don't specify version
versOUT = CLng(Left(objApp.Version, InStr(1, objApp.Version, ".") - 1))
objApp.Quit
Set objApp = Nothing
End Sub
versACC = CLng(objApp. Version)
...does not support etc
izy
__________________
currently using SS 2008R2
|
|

10-01-05, 10:04
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Quote:
|
Originally Posted by izyrider
so, correct me if i'm wrong, but i thought i needed the Office library to disappear command bars.
meanwhile, my late-bind experiments hit a brick wall
Code:
Private Sub uriGetVersion(versACC As Long, versXLS As Long, versOUT As Long)
Dim objApp As Application 'or object or nothing at all
Set objApp = CreateObject("Access.Application") ' Don't specify version
versACC = CLng(objApp.Version)
objApp.Quit
Set objApp = Nothing
Set objApp = CreateObject("Excel.Application") ' Don't specify version
versXLS = CLng(objApp.Version)
objApp.Quit
Set objApp = Nothing
Set objApp = CreateObject("Outlook.Application") ' Don't specify version
versOUT = CLng(Left(objApp.Version, InStr(1, objApp.Version, ".") - 1))
objApp.Quit
Set objApp = Nothing
End Sub
versACC = CLng(objApp. Version)
...does not support etc
izy
|
.Version isn't supported in Acc97, so you would have to use the SysCmd... not sure about Excel97/Outlook97 because I don't have them installed.
Can you not just do Access.CommandBars("Name").Visible = false ?? Or am I missing something? If you do need a library, which library is it?
|
Last edited by waynephillips; 10-01-05 at 10:07.
|

10-01-05, 10:12
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
there is no a97 involved.
the brick wall arrives in a2k in o2k on w2k
(...and is why i posted this earlier: i saw .version @msdn for 2k3 but couldn't make it go under 2k)
izy
__________________
currently using SS 2008R2
|
|

10-01-05, 10:14
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
and i've got this in stock for registry read/write (tho i didn't go thru it fully yet)
izy
__________________
currently using SS 2008R2
|
|

10-01-05, 10:16
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 261
|
|
Quote:
|
Originally Posted by izyrider
there is no a97 involved.
the brick wall arrives in a2k in o2k on w2k
(...and is why i posted this earlier: i saw .version @msdn for 2k3 but couldn't make it go under 2k)
izy
|
My mistake, you're quite right... it works in only Acc2k2/2k3.
It's still a bit nasty even if you get it working because you're having to create an instance of each application which consumes time and resources.
I'd go for the registry approach!
|
|

10-01-05, 10:21
|
|
Cavalier King Charles
|
|
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
|
|
thanks for all the input.
i'm attacking the registry now and i'll let you know how it goes.
izy
__________________
currently using SS 2008R2
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|