From: Peter T on 12 May 2010 08:20 "GS" <GS(a)discussions.microsoft.com> wrote in message news:uTDEUDc8KHA.980(a)TK2MSFTNGP04.phx.gbl... > Peter T has brought this to us : >> "GS" <GS(a)discussions.microsoft.com> wrote in message >> news:euEPvea8KHA.3880(a)TK2MSFTNGP04.phx.gbl... >> >>> I use COMAddins but I don't build my menus there; I use a xla for this >>> and redirect all controls' OnActions through a single procedure that >>> serves as an entry point to the COMAddin's procedures. It uses the >>> appropriate calls from within Excel to use the procedures inside the >>> COMAddin. (No code is in the xla other than what's required to >>> create/remove menus/toolbars. >> >> Curiosity, why bother making it a ComAddin if it's only going to be >> called from a UI created by your xla, with Onactions to your xla. IOW >> simply the xla as a wrapper to call the aX dll. You could dispense with >> the Connect class altogether. >> >> Regards, >> Peter T > > Hi Peter, > The only thing i use the xla for is to create/remove the menus/toolbar. > The UI Setup is created/removed by the COMAddin. There are 2 reasons I use > the xla to handle menus/toolbar[s]: > > 1. I use Rob Boveys commandbar builder table; > > 2. I provide plugin support for my apps. These are 'addins for my addin' > so to speak, whereby clients can add their own user-specific features and > functionality to the core app to enhance it specific to their needs. I > haven't yet figured out the VB6 mechanics of how to get this to work > in-process to my COMAddins and so using an xla to modify the menus/toolbar > with its own menus facilitates this easily. Also, since these are paid for > by the client then they actually own the source as well, and so this > facilitates them being able to work with that more easily than VB6 source. > > Why I 'bother' making COMAddins: > 1. Security! > Much of what I do comprises proprietary stuff of mine OR my clients. (ie: > business logic, dbase access passwords, user/password logins, etc) > > 2. Separate Threading > As you know, VBA stops when Excel starts working. COMAddins don't have > this limitation. Actually I didn't know that, are you sure! And even if it does, how does it help in practice. > > 3. Multiple Designer Class support > Not a major whistle but I do get requests for solutions that work in Excel > and Word. (Though, there's nothing much Word can do that can't be > duplicated with Excel, and without the 'bloat'!<IMO>) If you are not using any of the functionality of a ComAddin, other than installing it as such, this is a nor issue (I would have thought) > > 4. A COMAddin is the only current means to set up the ribbon in v12 or > higher via code. You must provide this through the designer. Sure, I could > make a separate xlsm/xlam just for that purpose, need to use the Custom UI > utility and all, but that's more bother than having a designer and less > secure to boot. Since the COMAddin is essentially the same as a DLL, the > advantages (for me at least) are worth it. (IOW, "the juice is worth the > squeeze!"<g>) I don't follow what you mean by ComAddin is the only way to set up the ribbon. Actually for me I found it quite a learning curve how to figure out how to do all that, the XML and the call-backs entirely in a ComAddin (much easier in an xlam!). I'm also confused, you say your xla handles all the menus in 2000/3 (even though can be done without an xla), yet in v12 you go the hard way and do it all in the ComAddin without an xlam. So are you saying are saying in v12 there is no VBA as the ribbon menu is entirely handled in the ComAddin. Or all the menu, callbacks etc is handled by VBA in an addin, if so I still done't follow why the need to install the ComAddin (vs simply an aX dll with xla wrapper). > 5. Menus we create in Excel need event hooking for callbacks, etc. and the > single OnAction in the xla obviates need for this. So.., the trade off for > this class is the designer, less code (and so smaller compiled size) since > there's no control event hooking or menu/toolbar building, and no need to > store button images/masks in a res. Swings and roundabouts I suppose, the menu builder and Click event (or Ribbon + callback) has to go somewhere. Likewise the button images (if you use custom ones) have to go somewhere. Regards, Peter T
From: GS on 12 May 2010 18:41 Peter T submitted this idea : > "GS" <GS(a)discussions.microsoft.com> wrote in message > news:uTDEUDc8KHA.980(a)TK2MSFTNGP04.phx.gbl... >> Peter T has brought this to us : >>> "GS" <GS(a)discussions.microsoft.com> wrote in message >>> news:euEPvea8KHA.3880(a)TK2MSFTNGP04.phx.gbl... >>> >>>> I use COMAddins but I don't build my menus there; I use a xla for this >>>> and redirect all controls' OnActions through a single procedure that >>>> serves as an entry point to the COMAddin's procedures. It uses the >>>> appropriate calls from within Excel to use the procedures inside the >>>> COMAddin. (No code is in the xla other than what's required to >>>> create/remove menus/toolbars. >>> >>> Curiosity, why bother making it a ComAddin if it's only going to be called >>> from a UI created by your xla, with Onactions to your xla. IOW simply the >>> xla as a wrapper to call the aX dll. You could dispense with the Connect >>> class altogether. >>> >>> Regards, >>> Peter T >> >> Hi Peter, >> The only thing i use the xla for is to create/remove the menus/toolbar. The >> UI Setup is created/removed by the COMAddin. There are 2 reasons I use the >> xla to handle menus/toolbar[s]: >> >> 1. I use Rob Boveys commandbar builder table; >> >> 2. I provide plugin support for my apps. These are 'addins for my addin' so >> to speak, whereby clients can add their own user-specific features and >> functionality to the core app to enhance it specific to their needs. I >> haven't yet figured out the VB6 mechanics of how to get this to work >> in-process to my COMAddins and so using an xla to modify the menus/toolbar >> with its own menus facilitates this easily. Also, since these are paid for >> by the client then they actually own the source as well, and so this >> facilitates them being able to work with that more easily than VB6 source. >> >> Why I 'bother' making COMAddins: >> 1. Security! >> Much of what I do comprises proprietary stuff of mine OR my clients. (ie: >> business logic, dbase access passwords, user/password logins, etc) >> >> 2. Separate Threading >> As you know, VBA stops when Excel starts working. COMAddins don't have this >> limitation. > > Actually I didn't know that, are you sure! And even if it does, how does it > help in practice. Excerpt from Professional Excel Development, Ch21: Exploiting Separate Threading "One of the more interesting things about COM Add-ins is that each one is given its own execution thread. The vast majority of Excel and VBA is single-threaded, meaning that VBA code stops when Excel is working (such as showing one of its dialogs) and vice versa. COM Add-ins don't have this limitation. A COM Add-in can initialize a Windows timer callback, tell Excel to display a dialog (or Print Preview or whatever), then continue processing (in the callback function) while Excel is still displaying the dialog. This allows us to (a) pre-populate the dialog, (b) watch what the user is doing within the dialog (and respond to it) and even (c) change the layout of the dialog itself!" > >> >> 3. Multiple Designer Class support >> Not a major whistle but I do get requests for solutions that work in Excel >> and Word. (Though, there's nothing much Word can do that can't be >> duplicated with Excel, and without the 'bloat'!<IMO>) > > If you are not using any of the functionality of a ComAddin, other than > installing it as such, this is a nor issue (I would have thought) Excerpt from Professional Excel Development, Ch21: Multi-Application Add-ins "A COM Add-in can contain multiple Designer classes, each handling the connection to a different Office application. Imagine an 'Insert Customer Details' add-in, which displayed a form allowing you select a customer from a central database and then inserted their name, address and/or telephone number in the current place in the document. By including multiple Designer classes in the add-in, we could easily make the add-in available to all the Office applications. Each class's OnConnection event would be used to add a standard menu item to the host application's command bars, with the click event handled by a single class. When clicked, it would display the form and would only branch into application-specific code when the 'Insert' button was clicked to insert the selected details into the cell, paragraph, field, presentation or web page." > >> >> 4. A COMAddin is the only current means to set up the ribbon in v12 or >> higher via code. You must provide this through the designer. Sure, I could >> make a separate xlsm/xlam just for that purpose, need to use the Custom UI >> utility and all, but that's more bother than having a designer and less >> secure to boot. Since the COMAddin is essentially the same as a DLL, the >> advantages (for me at least) are worth it. (IOW, "the juice is worth the >> squeeze!"<g>) > > I don't follow what you mean by ComAddin is the only way to set up the > ribbon. Actually for me I found it quite a learning curve how to figure out > how to do all that, the XML and the call-backs entirely in a ComAddin (much > easier in an xlam!). I stipulated 'via code'! It's actually easier to do in the COMAddin, NOT harder, because I don't need to use a separate xlam file for v12+, I don't need to use M$'s special Custom UI editor, and the xml is secure (as opposed to being in a workbook that anyone can edit as they please). I'm saying that INSTEAD of editing xml in a xlam, I pass the xml to Excel VIA CODE in the Designer. This is purely to handle the ribbon config, which (in most cases) basically removes everything except the Addins tab. My xla merely provides the menus/toolbar used for the COMAddin's runtime UI. These have a common entry point into the COMAddin. No callbacks are used or required (but I could optionally do that if/when needed). This requires setting refs to MSO12 AND Excel12 LIBs in the VB6 COMAddin's References dialog, and using the special interface designed for this purpose: Implements IRibbonExtensibility and using this function to load the xml: IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String IRibbonExtensibility_GetCustomUI = SetRibbonXML End Function SetRibbonXML is basically the same as what would be in a xlam's xml. In summary: The COMAddin handles all aspects of the UI except menus/toolbar. The XLA only handles menus/toolbar creation/removal. (for now) No separate xlam required for v12+. I'd be happy to help you in any way I can if you have interest in exploring this further. Essentially, besides a lot of back-and-forth with Rob, my main learning resources were: Professional Excel Development Excel 2007 VBA Developer's Reference and so I highly recommend these. Though, I suspect you may already have them.<g> Most of the back and forth with Rob concerned issues relavent to my goals that weren't covered in either book. I also studied Ron de Brun's materials to get ideas for setting up different UI scenarios. (Ditto the recommend/suspect you already have...) > I'm also confused, you say your xla handles all the > menus in 2000/3 (even though can be done without an xla), yet in v12 you go > the hard way and do it all in the ComAddin without an xlam. Nope! I'm saying I use the same xla for all versions. In earlier vers, my menus/toolbar are basically setup like dictator apps. In v12+ they appear on the Addins tab, which is the only tab I make available at runtime once the COMAddin passes the xml to Excel via the above function. Bear in mind that all my apps now use their own instance of Excel, except in cases where the client wants to add functionality to their default instance. In those cases I will usually provide a xla because that's likely going to be the only format they'll be able to access the source code in (if need be). Since they pay for it, it's their property. Every client, by default, has a VBIDE that they can use to access that source code. This is not likely to be the case for a VB6 COMAddin! > > So are you saying are saying in v12 there is no VBA as the ribbon menu is > entirely handled in the ComAddin. Or all the menu, callbacks etc is handled > by VBA in an addin, if so I still done't follow why the need to install the > ComAddin (vs simply an aX dll with xla wrapper). I'm saying that in any version there is no VBA in my xla other than whats necessary to create/remove the menus/toolbar. That is the only purpose (for now) of using the xla at all. I haven't got the mechanics for using the table-driven methodology figured out yet for doing this in VB6, but working on it so as to (eventually) not need XLAs. Once I resolve that part it's all going to be packaged inside the COMAddin for all x32 versions. > > >> 5. Menus we create in Excel need event hooking for callbacks, etc. and the >> single OnAction in the xla obviates need for this. So.., the trade off for >> this class is the designer, less code (and so smaller compiled size) since >> there's no control event hooking or menu/toolbar building, and no need to >> store button images/masks in a res. > > Swings and roundabouts I suppose, the menu builder and Click event (or Ribbon > + callback) has to go somewhere. No, that's not entirely true. If we create our menus for v12+ in our COMAddin then WE HAVE NO CHOICE but to implement a mechanism to handle hooking, callbacks, and icon images. Using the xla to manage our menus/toolbar obviates all need for that. They have a single entry point into our COMAddin. The COMAddin handles all its internal messaging as well as communications with/from Excel as per normal. So things like error handling and normal Excel events can be done by our COMAddin in a usual manner. The XLA commandbar builder utility has its own error handling and shutdown cleanup, and so our COMAddin doesn't need to be concerned with any of that either. Rob said he used to do commandbar building from a text file. I might do something similar with ADO and dump the file contents into a grid on a form, and just modify the code to walk through the grid as it now does a spreadsheet. Seems simple enough! > Likewise the button images (if you use custom ones) have to go somewhere. Yes they do. They (if custom) currently exist on the worksheet table for building menus/toolbar. Once I figure how I want to duplicate this table-driven methodology inside a VB6 COMAddin I will move them into a res. Meanwhile, all works flawlessly as expected to work and so no interuption for getting solutions to my clients. Everything we do can always be updated (or replaced with a newer ver). > Regards, > Peter T One thing I did not elaborate on is that my apps use their own instance of Excel. I guess that means I'll be disclosing some of my app architecture... Automating my own instance allows me to lock it down however I want, design whatever UI elements I want, and prevent users from using my instance for any other purpose than what it was designed for. (As said previously, some clients don't even realize they are using Excel!) Implementing this requires using a VB 'FrontLoader.exe'. This does all kinds of tests before it even allows startup, and if all tests pass it creates our instance, loads the COMAddin, and passes a 'ValidStartup' flag so the user can access functionality via the menus/toolbar. some tests include making sure the respective MSO apps are installed, making sure all required files/runtime components are available, and license validation. What I mean by 'loads the COMAddin' is that its StartupBehavior in the designer is deliberately set to '(None)' so that it doesn't appear in any Excel dialogs, or if manually added to a user instance it will not persist. Additionally, the COMAddin will not execute any internal code without the var gbValidStartup (flag) set to TRUE. This flag is an encrypted key that the frontloader passes after loading the COMAddin. Since COMAddins are a DLL just like any other DLL, its methods can be accessed at any time by any app. The only way to prevent unauthorized use is to restrict execution of its methods by any other means than our project provides. (As I said, some of my clients are overly security cautious; some are obsessed!) One side benefit of this to me is I can use that to turn off access for any reason (like payment not received within 30 days, for example). So by building this capability into the project's structure it makes it easy to say to clients: "Try it out for 30 days. Let me know if you want any changes made within that trial period. Otherwise, I expect to be fully paid if you plan to continue using it!". Kind of puts my time and effort at risk somewhat, but it hasn't been fruitless so far, thankfully.<bg> This feature is controlled by my licensing methodology, and so is included in the frontloader pre-satartup tests. Finally, the key to understanding why I use the xla at all is this: I fully develop in VBA in the earliest version expected to be used. since the commandbar builder components already exist, I just export all other mod/cls components to import into a COMAddin shell and go from there. All coding uses fully qualified refs (even with XL globals) so the only chore after importing the code is replacing any instances of 'Application' with my global var used for that (appXL). This only accounts for non-VB6 specific code. I continue development from their using the COMAddin from within whatever version I want to dev/test in, via a PERSONAL.XLS proc that mimics the frontloader startup routines. (Another side benefit of setting its StartupBehavior as mentioned) All code is made version-aware as required (by default). I can move from one ver to the other on my dev machine because I have it set up (currently) with v9 to v12 (no VM). I no longer dev for v9 and so I have 3 'clean' test machines (2x XPx32, 1 Win7x64) for stand-alone version testing. I did have a Vista machine but not long enough to bother setting it up as a test unit because I hated it and so gave it away to my daughter for business use. So, Peter, there you have it! Lots to digest, huh? Hey, I got nothing but time on my hands and so this is the sort of stuff I do with it. Regards, Garry
From: Peter T on 13 May 2010 10:14 "GS" <GS(a)discussions.microsoft.com> wrote in message news:ebrm8Qi8KHA.5900(a)TK2MSFTNGP04.phx.gbl... > Peter T submitted this idea : >> "GS" <GS(a)discussions.microsoft.com> wrote in message >> news:uTDEUDc8KHA.980(a)TK2MSFTNGP04.phx.gbl... >>> Peter T has brought this to us : >>>> "GS" <GS(a)discussions.microsoft.com> wrote in message <snip> >>> >>> 2. Separate Threading >>> As you know, VBA stops when Excel starts working. COMAddins don't have >>> this limitation. >> >> Actually I didn't know that, are you sure! And even if it does, how does >> it help in practice. > > Excerpt from Professional Excel Development, Ch21: > Exploiting Separate Threading > "One of the more interesting things about COM Add-ins is that each one is > given its own execution thread. The vast majority of Excel and VBA is > single-threaded, meaning that VBA code stops when Excel is working (such > as showing one of its dialogs) and vice versa. COM Add-ins don't have this > limitation. A COM Add-in can initialize a Windows timer callback, tell > Excel to display a dialog (or Print Preview or whatever), then continue > processing (in the callback function) while Excel is still displaying the > dialog. This allows us to (a) pre-populate the dialog, (b) watch what the > user is doing within the dialog (and respond to it) and even (c) change > the layout of the dialog itself!" Ah yes, guess I've never had need to take advantage of that possibility. >>> >>> 3. Multiple Designer Class support >>> Not a major whistle but I do get requests for solutions that work in >>> Excel and Word. (Though, there's nothing much Word can do that can't be >>> duplicated with Excel, and without the 'bloat'!<IMO>) >> >> If you are not using any of the functionality of a ComAddin, other than >> installing it as such, this is a nor issue (I would have thought) > > Excerpt from Professional Excel Development, Ch21: > Multi-Application Add-ins > "A COM Add-in can contain multiple Designer classes, each handling the > connection to a different Office application. Imagine an 'Insert Customer > Details' add-in, which displayed a form allowing you select a customer > from a central database and then inserted their name, address and/or > telephone number in the current place in the document. By including > multiple Designer classes in the add-in, we could easily make the add-in > available to all the Office applications. Each class's OnConnection event > would be used to add a standard menu item to the host application's > command bars, with the click event handled by a single class. When > clicked, it would display the form and would only branch into > application-specific code when the 'Insert' button was clicked to insert > the selected details into the cell, paragraph, field, presentation or web > page." OK, but although it's possible to include multiple 'Connect' classes for different apps, and stylistically that's probably a good idea, it's not necessary. In the Connection events can start with say a Select Case to cater for differing 'Application' object passed in the original OnConnection event. >>> >>> 4. A COMAddin is the only current means to set up the ribbon in v12 or >>> higher via code. You must provide this through the designer. Sure, I >>> could make a separate xlsm/xlam just for that purpose, need to use the >>> Custom UI utility and all, but that's more bother than having a designer >>> and less secure to boot. Since the COMAddin is essentially the same as a >>> DLL, the advantages (for me at least) are worth it. (IOW, "the juice is >>> worth the squeeze!"<g>) >> >> I don't follow what you mean by ComAddin is the only way to set up the >> ribbon. Actually for me I found it quite a learning curve how to figure >> out how to do all that, the XML and the call-backs entirely in a ComAddin >> (much easier in an xlam!). > > I stipulated 'via code'! It's actually easier to do in the COMAddin, NOT > harder, because I don't need to use a separate xlam file for v12+, I don't > need to use M$'s special Custom UI editor, and the xml is secure (as > opposed to being in a workbook that anyone can edit as they please). > > I'm saying that INSTEAD of editing xml in a xlam, I pass the xml to Excel > VIA CODE in the Designer. Sorry I don't follow "pass the xml". How/whereis the xml stored, how and when is it passed to Excel, then what does Excel do with it. FWIW, in the Connect class I do something like this Public Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String s = LoadResString(1001) IRibbonExtensibility_GetCustomUI = s where 1001 refers to the entire XML stored in th Resource > This is purely to handle the ribbon config, which (in most cases) > basically removes everything except the Addins tab. My xla merely provides > the menus/toolbar used for the COMAddin's runtime UI. These have a common > entry point into the COMAddin. No callbacks are used or required (but I > could optionally do that if/when needed). > > This requires setting refs to MSO12 AND Excel12 LIBs in the VB6 COMAddin's > References dialog, Indeed. That also means the if the dll is to cater for the Ribbon it means having different versions of the dll for 2000/3 and 2007+ (otherewise could simply set the reference to the lowest Excel version). > and using the special interface designed for this purpose: > Implements IRibbonExtensibility > > and using this function to load the xml: > IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String > IRibbonExtensibility_GetCustomUI = SetRibbonXML > End Function > SetRibbonXML is basically the same as what would be in a xlam's xml. > > In summary: > The COMAddin handles all aspects of the UI except menus/toolbar. > The XLA only handles menus/toolbar creation/removal. (for now) > No separate xlam required for v12+. Sorry I'm confused again, in v12 do you have an XLA(m). If the ComAddin already handles the entire Ribbon why do you need old style menus & toolbar in v12 (in the Addins tab). > > I'd be happy to help you in any way I can if you have interest in > exploring this further. Essentially, besides a lot of back-and-forth with > Rob, my main learning resources were: > Professional Excel Development > Excel 2007 VBA Developer's Reference I got the orignial version when it first came out, maybe I should look at the 2007 version! > > and so I highly recommend these. Though, I suspect you may already have > them.<g> Most of the back and forth with Rob concerned issues relavent to > my goals that weren't covered in either book. I also studied Ron de Brun's > materials to get ideas for setting up different UI scenarios. (Ditto the > recommend/suspect you already have...) Ron's site is a valuable resource (thanks Ron). I confess though I am still not fully up to speed with the Ribbon )-: > >> I'm also confused, you say your xla handles all the menus in 2000/3 (even >> though can be done without an xla), yet in v12 you go the hard way and do >> it all in the ComAddin without an xlam. > > Nope! I'm saying I use the same xla for all versions. In earlier vers, my > menus/toolbar are basically setup like dictator apps. In v12+ they appear > on the Addins tab, which is the only tab I make available at runtime once > the COMAddin passes the xml to Excel via the above function. I'm probably being real dumb here but if all your menus etc are in the Addins tab (ie same code to create and handle them as in previous versions), why do you need to be concerned with the Ribbon, Implements IRibbonExtensibility etc. > > Bear in mind that all my apps now use their own instance of Excel, except > in cases where the client wants to add functionality to their default > instance. In those cases I will usually provide a xla because that's > likely going to be the only format they'll be able to access the source > code in (if need be). Since they pay for it, it's their property. Every > client, by default, has a VBIDE that they can use to access that source > code. This is not likely to be the case for a VB6 COMAddin! I guess your app's are designed with very specific purposes in mind. >> So are you saying are saying in v12 there is no VBA as the ribbon menu is >> entirely handled in the ComAddin. Or all the menu, callbacks etc is >> handled by VBA in an addin, if so I still done't follow why the need to >> install the ComAddin (vs simply an aX dll with xla wrapper). > > I'm saying that in any version there is no VBA in my xla other than whats > necessary to create/remove the menus/toolbar. That is the only purpose > (for now) of using the xla at all. I haven't got the mechanics for using > the table-driven methodology figured out yet for doing this in VB6, but > working on it so as to (eventually) not need XLAs. Once I resolve that > part it's all going to be packaged inside the COMAddin for all x32 > versions. Ah, so it's just a matter of not yet getting around to moving the old-style toolbar creation and OnAction entirely into the ComAddin. <snip> > No, that's not entirely true. If we create our menus for v12+ in our > COMAddin then WE HAVE NO CHOICE but to implement a mechanism to handle > hooking, callbacks, and icon images. Using the xla to manage our > menus/toolbar obviates all need for that. They have a single entry point > into our COMAddin. The COMAddin handles all its internal messaging as well > as communications with/from Excel as per normal. So things like error > handling and normal Excel events can be done by our COMAddin in a usual > manner. Back to the my first thoughts again, apart from the Threading aspect there doesn't appear to be any need for the aX dll to be a ComAddin, right? Though I'm still unclear why you have some Ribbon stuff in a v12 version. > The XLA commandbar builder utility has its own error handling and shutdown > cleanup, and so our COMAddin doesn't need to be concerned with any of that > either. Think I know roughly what you have there but I've never found it a problem to do entirely within VB6, and without cells to lay out the menu details > > Rob said he used to do commandbar building from a text file. I might do > something similar with ADO and dump the file contents into a grid on a > form, and just modify the code to walk through the grid as it now does a > spreadsheet. Seems simple enough! Unless you've got a vast number of buttons simply a few har coded arrays. Or read from a text file. >> Likewise the button images (if you use custom ones) have to go somewhere. > > Yes they do. They (if custom) currently exist on the worksheet table for > building menus/toolbar. Once I figure how I want to duplicate this > table-driven methodology inside a VB6 COMAddin I will move them into a > res. > Meanwhile, all works flawlessly as expected to work and so no interuption > for getting solutions to my clients. Everything we do can always be > updated (or replaced with a newer ver). That of course is the main thing! > > One thing I did not elaborate on is that my apps use their own instance of > Excel. I guess that means I'll be disclosing some of my app > architecture... > > Automating my own instance allows me to lock it down however I want, > design whatever UI elements I want, and prevent users from using my > instance for any other purpose than what it was designed for. (As said > previously, some clients don't even realize they are using Excel!) > > Implementing this requires using a VB 'FrontLoader.exe'. This does all > kinds of tests before it even allows startup, and if all tests pass it > creates our instance, loads the COMAddin, and passes a 'ValidStartup' flag > so the user can access functionality via the menus/toolbar. some tests > include making sure the respective MSO apps are installed, making sure all > required files/runtime components are available, and license validation. > > What I mean by 'loads the COMAddin' is that its StartupBehavior in the > designer is deliberately set to '(None)' so that it doesn't appear in any > Excel dialogs, or if manually added to a user instance it will not > persist. Additionally, the COMAddin will not execute any internal code > without the var gbValidStartup (flag) set to TRUE. This flag is an > encrypted key that the frontloader passes after loading the COMAddin. > Since COMAddins are a DLL just like any other DLL, its methods can be > accessed at any time by any app. The only way to prevent unauthorized use > is to restrict execution of its methods by any other means than our > project provides. (As I said, some of my clients are overly security > cautious; some are obsessed!) One side benefit of this to me is I can use > that to turn off access for any reason (like payment not received within > 30 days, for example). So by building this capability into the project's > structure it makes it easy to say to clients: "Try it out for 30 days. Let > me know if you want any changes made within that trial period. Otherwise, > I expect to be fully paid if you plan to continue using it!". Kind of puts > my time and effort at risk somewhat, but it hasn't been fruitless so far, > thankfully.<bg> This feature is controlled by my licensing methodology, > and so is included in the frontloader pre-satartup tests. Interesting But on the limited time use don't you still need some sort of license/key combination. > > Finally, the key to understanding why I use the xla at all is this: I > fully develop in VBA in the earliest version expected to be used. since > the commandbar builder components already exist, I just export all other > mod/cls components to import into a COMAddin shell and go from there. All > coding uses fully qualified refs (even with XL globals) so the only chore > after importing the code is replacing any instances of 'Application' with > my global var used for that (appXL). This only accounts for non-VB6 > specific code. I continue development from their using the COMAddin from > within whatever version I want to dev/test in, via a PERSONAL.XLS proc > that mimics the frontloader startup routines. (Another side benefit of > setting its StartupBehavior as mentioned) FWIW I find if the reference is set to v9 and it compiles it should work for all versions. For specific later version stuff say with the range object, Dim objRng As Object (not range), then objRng.NewMethod will also compile. So no real need to develop in VBA at all. That said, a lot of things need to be rewritten in v12 irrespective of the reference issue. > > All code is made version-aware as required (by default). I can move from > one ver to the other on my dev machine because I have it set up > (currently) with v9 to v12 (no VM). I no longer dev for v9 and so I have 3 > 'clean' test machines (2x XPx32, 1 Win7x64) for stand-alone version > testing. I did have a Vista machine but not long enough to bother setting > it up as a test unit because I hated it and so gave it away to my daughter > for business use. > > So, Peter, there you have it! Lots to digest, huh? Hey, I got nothing but > time on my hands and so this is the sort of stuff I do with it. Yep, a lot there and thanks. I'm still a bit confused though about what's in the xla & the dll, especially re v12 Ribbon stuff. Regards, Peter T
From: GS on 13 May 2010 18:24 After serious thinking Peter T wrote : > "GS" <GS(a)discussions.microsoft.com> wrote in message > news:ebrm8Qi8KHA.5900(a)TK2MSFTNGP04.phx.gbl... >> Peter T submitted this idea : >>> "GS" <GS(a)discussions.microsoft.com> wrote in message >>> news:uTDEUDc8KHA.980(a)TK2MSFTNGP04.phx.gbl... >>>> Peter T has brought this to us : >>>>> "GS" <GS(a)discussions.microsoft.com> wrote in message > <snip> >>>> >>>> 2. Separate Threading >>>> As you know, VBA stops when Excel starts working. COMAddins don't have >>>> this limitation. >>> >>> Actually I didn't know that, are you sure! And even if it does, how does >>> it help in practice. >> >> Excerpt from Professional Excel Development, Ch21: >> Exploiting Separate Threading >> "One of the more interesting things about COM Add-ins is that each one is >> given its own execution thread. The vast majority of Excel and VBA is >> single-threaded, meaning that VBA code stops when Excel is working (such as >> showing one of its dialogs) and vice versa. COM Add-ins don't have this >> limitation. A COM Add-in can initialize a Windows timer callback, tell >> Excel to display a dialog (or Print Preview or whatever), then continue >> processing (in the callback function) while Excel is still displaying the >> dialog. This allows us to (a) pre-populate the dialog, (b) watch what the >> user is doing within the dialog (and respond to it) and even (c) change the >> layout of the dialog itself!" > > Ah yes, guess I've never had need to take advantage of that possibility. > >>>> >>>> 3. Multiple Designer Class support >>>> Not a major whistle but I do get requests for solutions that work in >>>> Excel and Word. (Though, there's nothing much Word can do that can't be >>>> duplicated with Excel, and without the 'bloat'!<IMO>) >>> >>> If you are not using any of the functionality of a ComAddin, other than >>> installing it as such, this is a nor issue (I would have thought) >> >> Excerpt from Professional Excel Development, Ch21: >> Multi-Application Add-ins >> "A COM Add-in can contain multiple Designer classes, each handling the >> connection to a different Office application. Imagine an 'Insert Customer >> Details' add-in, which displayed a form allowing you select a customer from >> a central database and then inserted their name, address and/or telephone >> number in the current place in the document. By including multiple Designer >> classes in the add-in, we could easily make the add-in available to all the >> Office applications. Each class's OnConnection event would be used to add a >> standard menu item to the host application's command bars, with the click >> event handled by a single class. When clicked, it would display the form >> and would only branch into application-specific code when the 'Insert' >> button was clicked to insert the selected details into the cell, paragraph, >> field, presentation or web page." > > OK, but although it's possible to include multiple 'Connect' classes for > different apps, and stylistically that's probably a good idea, it's not > necessary. In the Connection events can start with say a Select Case to cater > for differing 'Application' object passed in the original OnConnection event. While this may be doable, I don't think the intent of the text was to suggest doing it that way. My understanding of adding a separate designer for each use is so the appropriate flags/headers are set up in the DLL during compile so each MSO app can know it's there AND what its startup behavior should be. What you propose suggests that Word would intuitively know the Excel designer is not a Word COMAddin, and so how does it determine where to find its COMAddin designer when it won't load an Excel COMAddin? > >>>> >>>> 4. A COMAddin is the only current means to set up the ribbon in v12 or >>>> higher via code. You must provide this through the designer. Sure, I >>>> could make a separate xlsm/xlam just for that purpose, need to use the >>>> Custom UI utility and all, but that's more bother than having a designer >>>> and less secure to boot. Since the COMAddin is essentially the same as a >>>> DLL, the advantages (for me at least) are worth it. (IOW, "the juice is >>>> worth the squeeze!"<g>) >>> >>> I don't follow what you mean by ComAddin is the only way to set up the >>> ribbon. Actually for me I found it quite a learning curve how to figure >>> out how to do all that, the XML and the call-backs entirely in a ComAddin >>> (much easier in an xlam!). >> >> I stipulated 'via code'! It's actually easier to do in the COMAddin, NOT >> harder, because I don't need to use a separate xlam file for v12+, I don't >> need to use M$'s special Custom UI editor, and the xml is secure (as >> opposed to being in a workbook that anyone can edit as they please). >> >> I'm saying that INSTEAD of editing xml in a xlam, I pass the xml to Excel >> VIA CODE in the Designer. > > Sorry I don't follow "pass the xml". How/whereis the xml stored, how and when > is it passed to Excel, then what does Excel do with it. > > FWIW, in the Connect class I do something like this > > Public Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As > String > s = LoadResString(1001) > IRibbonExtensibility_GetCustomUI = s > > where 1001 refers to the entire XML stored in th Resource You've answered your own question! You store it in a res; I store it in a function (as indicated below). The reason I store it this way is because <IMO>it's easier to work with if I don't have to edit a res file. Another benefit to storing it in a function is that I can easily configure it for different startup scenarios. Using a res I would have to have a different one for each scenario. Keep in mind that we only get one shot at this, and thus we can't revise it after startup. I can change whatever I want on my menus/toolbars at runtime. > >> This is purely to handle the ribbon config, which (in most cases) basically >> removes everything except the Addins tab. My xla merely provides the >> menus/toolbar used for the COMAddin's runtime UI. These have a common entry >> point into the COMAddin. No callbacks are used or required (but I could >> optionally do that if/when needed). >> >> This requires setting refs to MSO12 AND Excel12 LIBs in the VB6 COMAddin's >> References dialog, > > Indeed. That also means the if the dll is to cater for the Ribbon it means > having different versions of the dll for 2000/3 and 2007+ (otherewise could > simply set the reference to the lowest Excel version). Not really! I use the same DLL for all versions. Since the earlier versions don't recognize IRibbonExtensibility then it's ignored (without raising an error). What reference context are you referring to here? > >> and using the special interface designed for this purpose: >> Implements IRibbonExtensibility >> >> and using this function to load the xml: >> IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String >> IRibbonExtensibility_GetCustomUI = SetRibbonXML >> End Function >> SetRibbonXML is basically the same as what would be in a xlam's xml. >> >> In summary: >> The COMAddin handles all aspects of the UI except menus/toolbar. >> The XLA only handles menus/toolbar creation/removal. (for now) >> No separate xlam required for v12+. > > Sorry I'm confused again, in v12 do you have an XLA(m). If the ComAddin > already handles the entire Ribbon why do you need old style menus & toolbar > in v12 (in the Addins tab). The COMAddin handles UI setup, which includes the ribbon. I do not have a separate xlam for v12. I use the same xla for all. In the earlier versions, my toolbar has IsMenubar set to TRUE so that the instance is only using my menus/toolbars. To duplicate this in v12 I need to get rid of the entire ribbon except for the Addins tab because that's where Excel put the menus/toolbars created by the xla. This then, mimics that the instance is only using my menus/toolbars. So in practice, why would I want to have separate COMAddins or XLAs for each when I have a working solution that does it all with one of each? Less to distribute, maintain and service! > >> >> I'd be happy to help you in any way I can if you have interest in exploring >> this further. Essentially, besides a lot of back-and-forth with Rob, my >> main learning resources were: >> Professional Excel Development >> Excel 2007 VBA Developer's Reference > > I got the orignial version when it first came out, maybe I should look at the > 2007 version! >> >> and so I highly recommend these. Though, I suspect you may already have >> them.<g> Most of the back and forth with Rob concerned issues relavent to >> my goals that weren't covered in either book. I also studied Ron de Brun's >> materials to get ideas for setting up different UI scenarios. (Ditto the >> recommend/suspect you already have...) > > Ron's site is a valuable resource (thanks Ron). I confess though I am still > not fully up to speed with the Ribbon )-: >> >>> I'm also confused, you say your xla handles all the menus in 2000/3 (even >>> though can be done without an xla), yet in v12 you go the hard way and do >>> it all in the ComAddin without an xlam. >> >> Nope! I'm saying I use the same xla for all versions. In earlier vers, my >> menus/toolbar are basically setup like dictator apps. In v12+ they appear >> on the Addins tab, which is the only tab I make available at runtime once >> the COMAddin passes the xml to Excel via the above function. > > I'm probably being real dumb here but if all your menus etc are in the Addins > tab (ie same code to create and handle them as in previous versions), why do > you need to be concerned with the Ribbon, Implements IRibbonExtensibility > etc. > >> >> Bear in mind that all my apps now use their own instance of Excel, except >> in cases where the client wants to add functionality to their default >> instance. In those cases I will usually provide a xla because that's likely >> going to be the only format they'll be able to access the source code in >> (if need be). Since they pay for it, it's their property. Every client, by >> default, has a VBIDE that they can use to access that source code. This is >> not likely to be the case for a VB6 COMAddin! > > I guess your app's are designed with very specific purposes in mind. Absolutely! Most of what I'm doing is task-driven and tailored to user-defined specifications. I also implement the same structure for my proprietary apps, though I haven't yet got them all converted over from workbook-based addins. I'd like to reach a point where I'm not dependant on M$O apps, but it's hard to do when clients insist on having that. The release of v12 and the ribbon concept is what set me off about continuing developing for M$O Excel. I plan to sever my proprietary apps over time, but may not also. (I have Farpoint Spread ActiveX, and so have already began the switch!) > > >>> So are you saying are saying in v12 there is no VBA as the ribbon menu is >>> entirely handled in the ComAddin. Or all the menu, callbacks etc is >>> handled by VBA in an addin, if so I still done't follow why the need to >>> install the ComAddin (vs simply an aX dll with xla wrapper). >> >> I'm saying that in any version there is no VBA in my xla other than whats >> necessary to create/remove the menus/toolbar. That is the only purpose (for >> now) of using the xla at all. I haven't got the mechanics for using the >> table-driven methodology figured out yet for doing this in VB6, but working >> on it so as to (eventually) not need XLAs. Once I resolve that part it's >> all going to be packaged inside the COMAddin for all x32 versions. > > Ah, so it's just a matter of not yet getting around to moving the old-style > toolbar creation and OnAction entirely into the ComAddin. Basically, that's correct. As for calling the menus/toolbar creation 'old-style', <IMO> Rob's table-driven system is 'state-of-the-art' compared to any others I've seen. So in terms of speaking 'old-style', constructing these line by line in a sub/function better qualifies as 'old-style', ..I would think! > > > <snip> >> No, that's not entirely true. If we create our menus for v12+ in our >> COMAddin then WE HAVE NO CHOICE but to implement a mechanism to handle >> hooking, callbacks, and icon images. Using the xla to manage our >> menus/toolbar obviates all need for that. They have a single entry point >> into our COMAddin. The COMAddin handles all its internal messaging as well >> as communications with/from Excel as per normal. So things like error >> handling and normal Excel events can be done by our COMAddin in a usual >> manner. > > Back to the my first thoughts again, apart from the Threading aspect there > doesn't appear to be any need for the aX dll to be a ComAddin, right? Though > I'm still unclear why you have some Ribbon stuff in a v12 version. You have just stated the primary reason why the DLL has to be a COMAddin. AFAIK, this is the only vehicle by which we can customize the ribbon via code. Otherwise, using an ordinary DLL would require also using separate addin workbooks. This will not fly with my security obsessed clients. I might use regular DLLs to add extensibility to my core apps if users want to enhance it with features/functionality specific to their use of my product. Since this use will vary between clients, I offer this by way of user-defined Plugins. If the app is Excel-based then it could also be provided as a xla that updates my menus/toolbar with their menus. In this respect, my addins also host other addins. This is harder to do in a VB6 project because VB doesn't have any built-in mechanism for hosting addins. The best solution to mimic this that I've been able to come up with so far is to call a DLL that displays a Form with menus/toolbar that looks and behaves like a floating toolbar. What I want is to be able to add menus to my menubar same as Excel does when we add menus to its menubar. Progress to this end is doubtful since VB is waining fast as a supported development language.<g> I want an approach that offers me advantages as a developer while also catering to client needs. I just don't see any sense in doing lots of extraneous work to do simple things. I'm productivity oriented in my thinking and so I try to reflect this in my work. I'm in the business of creating productivity solutions for others, and so that mindset causes me to use that thinking for myself, too. > > >> The XLA commandbar builder utility has its own error handling and shutdown >> cleanup, and so our COMAddin doesn't need to be concerned with any of that >> either. > > Think I know roughly what you have there but I've never found it a problem to > do entirely within VB6, and without cells to lay out the menu details I guess if you're used to doing this line by line in code then there's no change from normal for you. Line by line is how I started and converted to table-driven methodology as soon as I saw my first example. I can do line by line in a manner that's easy enough to follow and maintain, but it's going to be hard (now) for anyone to convince me that a table-driven system isn't a measureably better way to do this. > >> >> Rob said he used to do commandbar building from a text file. I might do >> something similar with ADO and dump the file contents into a grid on a >> form, and just modify the code to walk through the grid as it now does a >> spreadsheet. Seems simple enough! > > Unless you've got a vast number of buttons simply a few har coded arrays. Or > read from a text file. Well, I think storing the table data in a text file is the way I'll do it. I think using ADO to read that data as a recordset and dump it into a grid control might be best since the bBuildCommandbars routine is already design to walk through a table. I don't want to 're-invent the wheel'. I was thinking I'd move the code into the form class so it's an encapsulated component that I can drop into any VB6 COMAddin or Plugin.dll project so it serves both. Bear in mind that this is used only when complex menu structures are needed. Since I use it to modify built-in menus and create my own toolbars and popups, I'd like to have that flexibility for both core apps and Plugin DLLs. > >>> Likewise the button images (if you use custom ones) have to go somewhere. >> >> Yes they do. They (if custom) currently exist on the worksheet table for >> building menus/toolbar. Once I figure how I want to duplicate this >> table-driven methodology inside a VB6 COMAddin I will move them into a res. >> Meanwhile, all works flawlessly as expected to work and so no interuption >> for getting solutions to my clients. Everything we do can always be updated >> (or replaced with a newer ver). > > That of course is the main thing! > >> >> One thing I did not elaborate on is that my apps use their own instance of >> Excel. I guess that means I'll be disclosing some of my app architecture... >> >> Automating my own instance allows me to lock it down however I want, design >> whatever UI elements I want, and prevent users from using my instance for >> any other purpose than what it was designed for. (As said previously, some >> clients don't even realize they are using Excel!) >> >> Implementing this requires using a VB 'FrontLoader.exe'. This does all >> kinds of tests before it even allows startup, and if all tests pass it >> creates our instance, loads the COMAddin, and passes a 'ValidStartup' flag >> so the user can access functionality via the menus/toolbar. some tests >> include making sure the respective MSO apps are installed, making sure all >> required files/runtime components are available, and license validation. >> >> What I mean by 'loads the COMAddin' is that its StartupBehavior in the >> designer is deliberately set to '(None)' so that it doesn't appear in any >> Excel dialogs, or if manually added to a user instance it will not persist. >> Additionally, the COMAddin will not execute any internal code without the >> var gbValidStartup (flag) set to TRUE. This flag is an encrypted key that >> the frontloader passes after loading the COMAddin. Since COMAddins are a >> DLL just like any other DLL, its methods can be accessed at any time by any >> app. The only way to prevent unauthorized use is to restrict execution of >> its methods by any other means than our project provides. (As I said, some >> of my clients are overly security cautious; some are obsessed!) One side >> benefit of this to me is I can use that to turn off access for any reason >> (like payment not received within 30 days, for example). So by building >> this capability into the project's structure it makes it easy to say to >> clients: "Try it out for 30 days. Let me know if you want any changes made >> within that trial period. Otherwise, I expect to be fully paid if you plan >> to continue using it!". Kind of puts my time and effort at risk somewhat, >> but it hasn't been fruitless so far, thankfully.<bg> This feature is >> controlled by my licensing methodology, and so is included in the >> frontloader pre-satartup tests. > > Interesting > But on the limited time use don't you still need some sort of license/key > combination. Yes, that's true. I have a VB6-based licensing methodology worked out that can I use for both workbook-based addins and VB6 apps/dlls. I assume that your use of 'key' means the typical delimited serial-style text string used by many. I don't use these because for the amount of data that I store in a license code, they would be a paragraph rather than a limited length string of characters. Instead, I ship a License_Activator.exe that runs from within the app folder. > >> >> Finally, the key to understanding why I use the xla at all is this: I fully >> develop in VBA in the earliest version expected to be used. since the >> commandbar builder components already exist, I just export all other >> mod/cls components to import into a COMAddin shell and go from there. All >> coding uses fully qualified refs (even with XL globals) so the only chore >> after importing the code is replacing any instances of 'Application' with >> my global var used for that (appXL). This only accounts for non-VB6 >> specific code. I continue development from their using the COMAddin from >> within whatever version I want to dev/test in, via a PERSONAL.XLS proc that >> mimics the frontloader startup routines. (Another side benefit of setting >> its StartupBehavior as mentioned) > > FWIW I find if the reference is set to v9 and it compiles it should work for > all versions. For specific later version stuff say with the range object, Dim > objRng As Object (not range), then objRng.NewMethod will also compile. So no > real need to develop in VBA at all. That said, a lot of things need to be > rewritten in v12 irrespective of the reference issue. Hmm! I think I prefer to develop for later version stuff in that version and using normal references as pertains to each. I guess it's just my nature to always be testing as I go, and so having multiple versions installed on my dev machine provides me the convenience to have instances of each version running simultaneously. In order to test a COMAddin we have to close all instances of Excel, compile it, reopen all instances of Excel to test. Again, why take the long way around when the code is portable between the two? > >> >> All code is made version-aware as required (by default). I can move from >> one ver to the other on my dev machine because I have it set up (currently) >> with v9 to v12 (no VM). I no longer dev for v9 and so I have 3 'clean' test >> machines (2x XPx32, 1 Win7x64) for stand-alone version testing. I did have >> a Vista machine but not long enough to bother setting it up as a test unit >> because I hated it and so gave it away to my daughter for business use. >> >> So, Peter, there you have it! Lots to digest, huh? Hey, I got nothing but >> time on my hands and so this is the sort of stuff I do with it. > > Yep, a lot there and thanks. Sure! Bear in mind that the approach I've discussed here is my purposed method to mimic using dictator style addins as efficiently as possible across all versions. This does not discount that what we would do for a normal Excel addin isn't viable. I would be doing those same things the same way in those cases where my users want my solutions available in their standard instance of Excel. I guess because I was forced to take this approach to serve client needs, I've had to travel down a not too well travelled path to get here. I don't mind sharing that, or even hearing suggestions that might be an improvement. > I'm still a bit confused though about what's in the xla & the dll, > especially re v12 Ribbon stuff. Well, I certainly was confused about ribbon stuff too at first. I hope our dialog leaves you a bit less confused now, though. I guess what it ultimately boils down to is what you're trying to achieve in the end. In using workbook-based addins there's no choice if we want to customize the ribbon because we have to do that within the workbook xml. Bob Phillip's example is the best I've seen yet for handling that. Using automated instances just gives us more flexibility and overall control over tailoring the UI for our purposes<IMO> because we're not messing with the user's default instance. (<FWIW>I strongly support the notion to NEVER hijack a running instance for any reason whatsoever) > > Regards, > Peter T regards, Garry
From: Peter T on 14 May 2010 10:26 "GS" <GS(a)discussions.microsoft.com> wrote in message news:eQIPCsu8KHA.980(a)TK2MSFTNGP04.phx.gbl... > After serious thinking Peter T wrote : >> "GS" <GS(a)discussions.microsoft.com> wrote in message <snip> > > While this may be doable, I don't think the intent of the text was to > suggest doing it that way. My understanding of adding a separate designer > for each use is so the appropriate flags/headers are set up in the DLL > during compile so each MSO app can know it's there AND what its startup > behavior should be. What you propose suggests that Word would intuitively > know the Excel designer is not a Word COMAddin, and so how does it > determine where to find its COMAddin designer when it won't load an Excel > COMAddin? Ah there is that! Goes to show I've never made a ComAddin for multiple apps. > >> >>>>> >>>>> 4. A COMAddin is the only current means to set up the ribbon in v12 or >>>>> higher via code. You must provide this through the designer. Sure, I >>>>> could make a separate xlsm/xlam just for that purpose, need to use the >>>>> Custom UI utility and all, but that's more bother than having a >>>>> designer and less secure to boot. Since the COMAddin is essentially >>>>> the same as a DLL, the advantages (for me at least) are worth it. >>>>> (IOW, "the juice is worth the squeeze!"<g>) >>>> >>>> I don't follow what you mean by ComAddin is the only way to set up the >>>> ribbon. Actually for me I found it quite a learning curve how to figure >>>> out how to do all that, the XML and the call-backs entirely in a >>>> ComAddin (much easier in an xlam!). >>> >>> I stipulated 'via code'! It's actually easier to do in the COMAddin, NOT >>> harder, because I don't need to use a separate xlam file for v12+, I >>> don't need to use M$'s special Custom UI editor, and the xml is secure >>> (as opposed to being in a workbook that anyone can edit as they please). >>> >>> I'm saying that INSTEAD of editing xml in a xlam, I pass the xml to >>> Excel VIA CODE in the Designer. >> >> Sorry I don't follow "pass the xml". How/whereis the xml stored, how and >> when is it passed to Excel, then what does Excel do with it. >> >> FWIW, in the Connect class I do something like this >> >> Public Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As >> String) As String >> s = LoadResString(1001) >> IRibbonExtensibility_GetCustomUI = s >> >> where 1001 refers to the entire XML stored in th Resource > > You've answered your own question! You store it in a res; I store it in a > function (as indicated below). The reason I store it this way is because > <IMO>it's easier to work with if I don't have to edit a res file. I agree sorting large xml in a resource is not the easiest but I've made my own little app to put the xml and anything else into a resource file. It is a bit of hassle, though could easly read the xml from say a text file. You say your strore the xml in a function 'below', I can't see it for looking and still not clear if you keep the xml in the VB6 (if so how) or somewhere else. >> >>> This is purely to handle the ribbon config, which (in most cases) >>> basically removes everything except the Addins tab. My xla merely >>> provides the menus/toolbar used for the COMAddin's runtime UI. These >>> have a common entry point into the COMAddin. No callbacks are used or >>> required (but I could optionally do that if/when needed). >>> >>> This requires setting refs to MSO12 AND Excel12 LIBs in the VB6 >>> COMAddin's References dialog, >> >> Indeed. That also means the if the dll is to cater for the Ribbon it >> means having different versions of the dll for 2000/3 and 2007+ >> (otherewise could simply set the reference to the lowest Excel version). > > Not really! I use the same DLL for all versions. Since the earlier > versions don't recognize IRibbonExtensibility then it's ignored (without > raising an error). I don't follow that at all. If the Office ref is v11 or less the following DO NOT compile Implements IRibbonExtensibility Public Function MyRibbonButton(ByVal control As Office.IRibbonControl) 'code End Function Unless I'm missing something it the dll needs to handle the Ribbon and call backs it means making entirely separate versions for 2000/3 and 2007+, with references to Office/Excel v9 & v12 respectively. Alternatively, there's no problem for a ComAddin with the v9/2000 ref's to work in 2007 providing it only uses old-style commandbar type buttons which end up in 2007's addins tab. > > What reference context are you referring to here? >> >>> and using the special interface designed for this purpose: >>> Implements IRibbonExtensibility >>> >>> and using this function to load the xml: >>> IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String >>> IRibbonExtensibility_GetCustomUI = SetRibbonXML >>> End Function >>> SetRibbonXML is basically the same as what would be in a xlam's xml. >>> >>> In summary: >>> The COMAddin handles all aspects of the UI except menus/toolbar. >>> The XLA only handles menus/toolbar creation/removal. (for now) >>> No separate xlam required for v12+. >> >> Sorry I'm confused again, in v12 do you have an XLA(m). If the ComAddin >> already handles the entire Ribbon why do you need old style menus & >> toolbar in v12 (in the Addins tab). > > The COMAddin handles UI setup, which includes the ribbon. I do not have a > separate xlam for v12. I use the same xla for all. In the earlier > versions, my toolbar has IsMenubar set to TRUE so that the instance is > only using my menus/toolbars. To duplicate this in v12 I need to get rid > of the entire ribbon except for the Addins tab because that's where Excel > put the menus/toolbars created by the xla. This then, mimics that the > instance is only using my menus/toolbars. I'm still missing something, not to worry, no doubt it'd all be obvious if I saw it. > > So in practice, why would I want to have separate COMAddins or XLAs for > each when I have a working solution that does it all with one of each? > Less to distribute, maintain and service! Obviously it works for you but still not following as explained a couple of sections above. <snip> >>> >>> Bear in mind that all my apps now use their own instance of Excel, >>> except in cases where the client wants to add functionality to their >>> default instance. In those cases I will usually provide a xla because >>> that's likely going to be the only format they'll be able to access the >>> source code in (if need be). Since they pay for it, it's their property. >>> Every client, by default, has a VBIDE that they can use to access that >>> source code. This is not likely to be the case for a VB6 COMAddin! >> >> I guess your app's are designed with very specific purposes in mind. > > Absolutely! Most of what I'm doing is task-driven and tailored to > user-defined specifications. I also implement the same structure for my > proprietary apps, though I haven't yet got them all converted over from > workbook-based addins. > > I'd like to reach a point where I'm not dependant on M$O apps, but it's > hard to do when clients insist on having that. The release of v12 and the > ribbon concept is what set me off about continuing developing for M$O > Excel. I plan to sever my proprietary apps over time, but may not also. (I > have Farpoint Spread ActiveX, and so have already began the switch!) Without M$O apps, sounds ambitious though no doubt it depends on what you are doing. <snip> >> >> Ah, so it's just a matter of not yet getting around to moving the >> old-style toolbar creation and OnAction entirely into the ComAddin. > > Basically, that's correct. As for calling the menus/toolbar creation > 'old-style', <IMO> Rob's table-driven system is 'state-of-the-art' > compared to any others I've seen. So in terms of speaking 'old-style', > constructing these line by line in a sub/function better qualifies as > 'old-style', ..I would think! Misunderstanding, by 'old-style' I meant commandbars etc as available to 97-2003 vs 'new-ribbon' in 2007, nothing to do with whatever approach you use to create them, >> >> <snip> > > I might use regular DLLs to add extensibility to my core apps if users > want to enhance it with features/functionality specific to their use of my > product. Since this use will vary between clients, I offer this by way of > user-defined Plugins. If the app is Excel-based then it could also be > provided as a xla that updates my menus/toolbar with their menus. In this > respect, my addins also host other addins. This is harder to do in a VB6 > project because VB doesn't have any built-in mechanism for hosting addins. > The best solution to mimic this that I've been able to come up with so far > is to call a DLL that displays a Form with menus/toolbar that looks and > behaves like a floating toolbar. What I want is to be able to add menus to > my menubar same as Excel does when we add menus to its menubar. Progress > to this end is doubtful since VB is waining fast as a supported > development language.<g> Your main ComAddin could also run a whole series of other aX dll's, some of which might display there own set of forms. If that's what you're aiming at. > > I want an approach that offers me advantages as a developer while also > catering to client needs. I just don't see any sense in doing lots of > extraneous work to do simple things. I'm productivity oriented in my > thinking and so I try to reflect this in my work. I'm in the business of > creating productivity solutions for others, and so that mindset causes me > to use that thinking for myself, too. Sounds like you've got a pretty strong grip on your works > > I guess if you're used to doing this line by line in code then there's no > change from normal for you. Line by line is how I started and converted to > table-driven methodology as soon as I saw my first example. I know the table driven way but I don't have any problem 'laying out' a series of arrays of UI data which looks logical to me. <snip> >> >> FWIW I find if the reference is set to v9 and it compiles it should work >> for all versions. For specific later version stuff say with the range >> object, Dim objRng As Object (not range), then objRng.NewMethod will also >> compile. So no real need to develop in VBA at all. That said, a lot of >> things need to be rewritten in v12 irrespective of the reference issue. > > Hmm! I think I prefer to develop for later version stuff in that version > and using normal references as pertains to each. I guess it's just my > nature to always be testing as I go, and so having multiple versions > installed on my dev machine provides me the convenience to have instances > of each version running simultaneously. But I thouht you only wanted the one version of your aComAddin for all Excel versions, I must be misunderstanding again. > > In order to test a COMAddin we have to close all instances of Excel, > compile it, reopen all instances of Excel to test. Again, why take the > long way around when the code is portable between the two? Testing a ComAddin is a bit of a pain because it needs to get the connection event, as you say it means starting a new instance of Excel each time (though no need to close all instances). A workaround is to add a temporary entry class that can be called from a small macro. Then call a public proc in the entry class to go to where ever in the dll you would normally go. But thinking about it, you are normally activating via VBA anyway, aren't you, so the ComAddin problem shouldn't exist for you, I would have thought. <snip> Regards, Peter T
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Sort by one column then another. Next: Figuring out MAX LEN in a given column |