Posts 1 - 10 of 15
First | Prev. | 1 2 | Next | Last
|
|
|
|
Mark Exactal
Guest
|
Hi,
I am trying to add an item to the right click context menu in Excel.
I have searched the forum and there is a reference to use OnSheetBeforeRightClick but no example.
There is an example in C sharp but I have difficulty using it because I don't know C sharp.
Any chance of a quick example in Delphi?
Thanks for all your help guys.
Cheers
Mark |
|
|
Posted 08 May, 2008 06:51:59
|
|
Top
|
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi Mark,
You need to do the following:
1. Add a new TadxCommandBar component to your add-in module.
2. Set the CommandBarName property to 'Cell'.
3. Populate the Controls collection with your buttons.
|
|
|
Posted 08 May, 2008 06:58:19
|
|
Top
|
|
|
Mark Exactal
Guest
|
Hi Dmitry,
I did that but with no effect. After I created the TadxCommandBar and went into Excel, right click did not have any new items. I tried it with BeginGroup set to true and false.
So you can check what I did, the definition from the dfm is as follows:
object ftbMenu: TadxCommandBar
SupportedApps = [ohaExcel]
CommandBarName = 'Cell'
Left = 156
Top = 80
ButtonTypes = {0100000000000000}
Buttons = <
item
Caption = 'Do something'
OfficeTag = '{ADCA3BFA-41D4-480B-8E2F-6A3A45BD812F}'
olExplorerItemTypes = []
olInspectorItemTypes = []
OnClick = ftbMenuControls0Click
PropertyChanged = 7
end>
PropertyChanged = 3
end
Also how does this work on a cell by cell basis? What I want to do is read the contents of the cell before I decide whether to add items to the context menu or not.
Thanks
Mark
|
|
|
Posted 08 May, 2008 18:58:53
|
|
Top
|
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
|
|
Posted 09 May, 2008 06:53:36
|
|
Top
|
|
|
Mark Exactal
Guest
|
Hi Dmitry,
Downloaded the sample and installed it. Registered the dll and put a trace on the code. Everything executes but nothing shows in the right click menu!
Enviroment is 2007 Office on XP SP3 (I had the same problems on SP2 as I have only recently upgraded). I am now running Add-In-Express Premium subscription for 2008.
Any thoughts on where I should look would be welcome.
Cheers
Mark |
|
|
Posted 09 May, 2008 08:59:25
|
|
Top
|
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi Mark,
Oh, sorry, it was my fault. Please set the TadxCommandBar.UseForRibbon property to True and retest the demo project.
|
|
|
Posted 09 May, 2008 09:13:39
|
|
Top
|
|
|
Mark Exactal
Guest
|
Thanks Dmitry. I thought I was going crazy but changing the setting worked perfectly.
Now for a really crazy one...
After I starting using the right click functionality I noticed that if I executed any of the built in commands that I have written, the beforerightclick event gets fired twice. Before you execute a built in command it will only execute once but afterwards always twice regardless of which cell you are pointing at.
To make sure it is not something I have done, I altered the demo you just sent me to add 1 function. Before you call the function beforerightclick fires once when you right click, after you execute the function, beforerightclick fires twice.
I can send you the sample by e-mail if you want.
Let me know what you find out.
Cheers
Mark
|
|
|
Posted 11 May, 2008 22:30:20
|
|
Top
|
|
|
Mark Exactal
Guest
|
I have an update that makes it even weirder :)
If you dissociate the BeforeRightClick function from the event, the function attached to the command bar button still executes twice as soon as you have executed one of your build in functions. I therefore thought there is no bug with the BeforeRightClick but the interesting thing is that if you reassociate the BeforeRightClick function with the event and insert a SendMessage in the function you will see that it is also called twice.
So once you have executed any built-in function you have created, BeforeRightClick executes twice and so does the code associated with the actual click event.
I have sent you the original sample via e-mail.
Hope this helps.
Cheers
Mark
|
|
|
Posted 12 May, 2008 01:56:52
|
|
Top
|
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi Mark,
For some reason I didn't get your demo project. Could you please resend it? You can find our support email address in the readme.txt file located in the Add-in Express installation folder.
|
|
|
Posted 12 May, 2008 07:44:31
|
|
Top
|
|
|
Mark K
Guest
|
Hi Dmitry,
I have resent it but I already had the same address.
Just in case it gets blocked again I will give you the instructions to make it occur as it is quite easy to replicate.
1. Open the demo project that you sent me.
2. Open the TLB and add a method. In my case I called it ADXMETHOD1. It had one input parameter and one output parameter result.
3. Refresh the implementation and in the code just set the result to be anything but I used 'XX'.
4. Change the XLAutomationAddIn property to True on the add in module and compile the code.
5. I found that I needed to unregister the dll and reregister it to get the XLAutomationAddIN property to work.
If you now run Excel you will see that you can right click and select 'Do Something' and the 'Click' message will only appear once. If you then type '=ADXMETHOD1("aa")' into any cell and then try a right click when you select 'Do Something' you will get the 'Click' message twice. If you add a SendMessage into the BeforeRightClick function you will see that it is also executed twice after you have entered the build in function.
Hopefully this helps solve it.
Cheers
Mark |
|
|
Posted 12 May, 2008 09:49:00
|
|
Top
|
|
|
Posts 1 - 10 of 15
First | Prev. | 1 2 | Next | Last
|