Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there any way of writing write code in an Excel95 workbook which
creates a CommandBar object (as distinct from a Toolbar object) when opened in later versions i.e. code must work in Excel97 onwards but not blow up in Excel95? My first thought was conditional compilation but I find it's not supported in Excel95 (VBA4?) My second thought was to create an instance using late binding but this won't work either. Not surprising because I know I can't instantiate a CommandBar using early binding anyway i.e. Dim oBar As Office.CommandBar Set oBar = New Office.CommandBar ' << compile error Any other ideas (or confirmation this just isn't possible)? -- |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jamieuk,
Is there any way of writing write code in an Excel95 workbook which creates a CommandBar object (as distinct from a Toolbar object) when opened in later versions i.e. code must work in Excel97 onwards but not blow up in Excel95? Write the code in a separate sub that is only called when the later version opens your workbook. You will get a compile error when you manually compile (not sure if Excel 95 could do that), but it should run OK on both systems, since VBA only compiles a sub when it is called. Regards, Jan Karel Pieterse Excel MVP www.jkp-ads.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the suggestion but it didn't work I'm afraid. I wrote this
sub which is never called: Sub NeverNever() Dim c As CommandBar End Sub But when I tried to run my sub main I got an error, 'User Defined type not defined', which I suppose is the xl95 equivalent of a compile error because my sub main didn't run at all. -- Jan Karel Pieterse wrote in message ... Hi Jamieuk, Is there any way of writing write code in an Excel95 workbook which creates a CommandBar object (as distinct from a Toolbar object) when opened in later versions i.e. code must work in Excel97 onwards but not blow up in Excel95? Write the code in a separate sub that is only called when the later version opens your workbook. You will get a compile error when you manually compile (not sure if Excel 95 could do that), but it should run OK on both systems, since VBA only compiles a sub when it is called. Regards, Jan Karel Pieterse Excel MVP www.jkp-ads.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Onedaywhen,
Thanks for the suggestion but it didn't work I'm afraid. I wrote this sub which is never called: Sub NeverNever() Dim c As CommandBar Maybe defining c as an object will pass the test? Or maybe putting all non-95 stuff in a separate module? Regards, Jan Karel Pieterse Excel MVP www.jkp-ads.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
JKP,
Good thinking! When I put sub NeverNever in a separate module I get no error. Many thanks. -- Jan Karel Pieterse wrote in message ... Hi Onedaywhen, Thanks for the suggestion but it didn't work I'm afraid. I wrote this sub which is never called: Sub NeverNever() Dim c As CommandBar Maybe defining c as an object will pass the test? Or maybe putting all non-95 stuff in a separate module? Regards, Jan Karel Pieterse Excel MVP www.jkp-ads.com |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Onedaywhen,
When I put sub NeverNever in a separate module I get no error. Good, another problem solved! Regards, Jan Karel Pieterse Excel MVP www.jkp-ads.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Xfer of XL95 custom menus into XL97 | Excel Worksheet Functions | |||
Editing XL95 custom menus with XL97 | Excel Worksheet Functions | |||
Cannot create transparent XP CommandBar picture | Excel Programming | |||
Create new commandbar with call procedure | Excel Programming | |||
VBA for XL95, Workbook.open non XL-file | Excel Programming |