Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-04-2008, 02:47 PM
martin.j.jung@googlemail.com
 
Posts: n/a
Adding Context Menu (right click) Options

Hello,

I try to add a context menu to an excel sheet. The problem is that I
can not identify the current commandbar as it seems that this
commandbar is different wether you are in "normal view" or - and
that
is the problem here - you are in "page Break Preview". If the sheet
is
in the normal view the following code works fine, but not if I am in
the "page Break Preview" Mode. I assume the commandbar will even
change if I have a comment in the cell or not and so on ... Is there
a
way to identify the commandbar that will pop up after the
"BeforeRightClick"-Event?

At the moment I have to following code in my worksheet and it works
fine during "normal view" but it does not work during "page Break
Preview"

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
On Error Resume Next
cmdid = Application.CommandBars("Cell").ID
' cmdid = 427
With Application
.CommandBars(cmdid).Controls("Update Work Center in
SAP").Delete
Set cBut
= .CommandBars(cmdid).Controls.Add(Temporary:=True)
End With


With cBut
.Caption = "Update Work Center in SAP"
.Style = msoButtonCaption
.OnAction = "change_workcenter"
.Parameter = Format(Target.value)
End With
On Error GoTo 0
End Sub


Reply With Quote
  #2 (permalink)  
Old 09-04-2008, 05:08 PM
Bob Phillips
 
Posts: n/a
Re: Adding Context Menu (right click) Options

It too is called Cell, with an Id of 427 (as against the normal 424).

Do a Findcontrol on both by Id and add to each control.

--
__________________________________
HTH

Bob

<martin.j.jung@googlemail.com> wrote in message
news:42ccfff6-d4e7-4059-bf72-4de5abb92e7c@1g2000pre.googlegroups.com...
> Hello,
>
> I try to add a context menu to an excel sheet. The problem is that I
> can not identify the current commandbar as it seems that this
> commandbar is different wether you are in "normal view" or - and
> that
> is the problem here - you are in "page Break Preview". If the sheet
> is
> in the normal view the following code works fine, but not if I am in
> the "page Break Preview" Mode. I assume the commandbar will even
> change if I have a comment in the cell or not and so on ... Is there
> a
> way to identify the commandbar that will pop up after the
> "BeforeRightClick"-Event?
>
> At the moment I have to following code in my worksheet and it works
> fine during "normal view" but it does not work during "page Break
> Preview"
>
> Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
> As Boolean)
> On Error Resume Next
> cmdid = Application.CommandBars("Cell").ID
> ' cmdid = 427
> With Application
> .CommandBars(cmdid).Controls("Update Work Center in
> SAP").Delete
> Set cBut
> = .CommandBars(cmdid).Controls.Add(Temporary:=True)
> End With
>
>
> With cBut
> .Caption = "Update Work Center in SAP"
> .Style = msoButtonCaption
> .OnAction = "change_workcenter"
> .Parameter = Format(Target.value)
> End With
> On Error GoTo 0
> End Sub
>
>



Reply With Quote
  #3 (permalink)  
Old 09-04-2008, 05:54 PM
Dave Peterson
 
Posts: n/a
Re: Adding Context Menu (right click) Options

I think that id number varied in different versions of excel.

But (so far!), the pagebreak cell id was 3 more than the normal cell id.



Bob Phillips wrote:
>
> It too is called Cell, with an Id of 427 (as against the normal 424).
>
> Do a Findcontrol on both by Id and add to each control.
>
> --
> __________________________________
> HTH
>
> Bob
>
> <martin.j.jung@googlemail.com> wrote in message
> news:42ccfff6-d4e7-4059-bf72-4de5abb92e7c@1g2000pre.googlegroups.com...
> > Hello,
> >
> > I try to add a context menu to an excel sheet. The problem is that I
> > can not identify the current commandbar as it seems that this
> > commandbar is different wether you are in "normal view" or - and
> > that
> > is the problem here - you are in "page Break Preview". If the sheet
> > is
> > in the normal view the following code works fine, but not if I am in
> > the "page Break Preview" Mode. I assume the commandbar will even
> > change if I have a comment in the cell or not and so on ... Is there
> > a
> > way to identify the commandbar that will pop up after the
> > "BeforeRightClick"-Event?
> >
> > At the moment I have to following code in my worksheet and it works
> > fine during "normal view" but it does not work during "page Break
> > Preview"
> >
> > Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
> > As Boolean)
> > On Error Resume Next
> > cmdid = Application.CommandBars("Cell").ID
> > ' cmdid = 427
> > With Application
> > .CommandBars(cmdid).Controls("Update Work Center in
> > SAP").Delete
> > Set cBut
> > = .CommandBars(cmdid).Controls.Add(Temporary:=True)
> > End With
> >
> >
> > With cBut
> > .Caption = "Update Work Center in SAP"
> > .Style = msoButtonCaption
> > .OnAction = "change_workcenter"
> > .Parameter = Format(Target.value)
> > End With
> > On Error GoTo 0
> > End Sub
> >
> >


--

Dave Peterson
Reply With Quote
  #4 (permalink)  
Old 09-04-2008, 06:41 PM
martin.j.jung@googlemail.com
 
Posts: n/a
Re: Adding Context Menu (right click) Options

On Sep 4, 6:54*pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> I think that id number varied in different versions of excel.
>
> But (so far!), the pagebreak cell id was 3 more than the normal cell id.
>
>
>
>
>
> Bob Phillips wrote:
>
> > It too is called Cell, with an Id of 427 (as against the normal 424).

>
> > Do a Findcontrol on both by Id and add to each control.

>
> > --
> > __________________________________
> > HTH

>
> > Bob

>
> > <martin.j.j...@googlemail.com> wrote in message
> >news:42ccfff6-d4e7-4059-bf72-4de5abb92e7c@1g2000pre.googlegroups.com...
> > > Hello,

>
> > > I try to add a context menu to an excel sheet. The problem is that I
> > > can not identify the current commandbar as it seems that this
> > > commandbar is different wether you are in "normal view" or *- and
> > > that
> > > is the problem here - you are in "page Break Preview". If the sheet
> > > is
> > > in the normal view the following code works fine, but not if I am in
> > > the "page Break Preview" Mode. I assume the commandbar will even
> > > change if I have a comment in the cell or not and so on ... Is there
> > > a
> > > way to identify the commandbar that will pop up after the
> > > "BeforeRightClick"-Event?

>
> > > At the moment I have to following code in my worksheet and it works
> > > fine during "normal view" but it does not work during "page Break
> > > Preview"

>
> > > Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
> > > As Boolean)
> > > On Error Resume Next
> > > * * * *cmdid = Application.CommandBars("Cell").ID
> > > ' * * * *cmdid = 427
> > > * * * *With Application
> > > * * * * * *.CommandBars(cmdid).Controls("Update Work Center in
> > > SAP").Delete
> > > * * * * * *Set cBut
> > > = .CommandBars(cmdid).Controls.Add(Temporary:=True)
> > > * * * *End With

>
> > > * * * *With cBut
> > > * * * * * .Caption = "Update Work Center in SAP"
> > > * * * * * .Style = msoButtonCaption
> > > * * * * * .OnAction = "change_workcenter"
> > > * * * * * .Parameter = Format(Target.value)
> > > * * * *End With
> > > * *On Error GoTo 0
> > > End Sub

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


Thanks for your answer ...

I tried it and it worked but is there a way to get the current
commandbar, irrespective what view I have?
Meanwhile I have learned that I have to use even another commandbar,
if in the cell that is under the cursor is attached to a query from a
database...
Reply With Quote
  #5 (permalink)  
Old 09-04-2008, 07:32 PM
Dave Peterson
 
Posts: n/a
Re: Adding Context Menu (right click) Options

Personally, I'd just add the options I want to each of those Cell commandbars.

But if you want, you could look at the activewindow.

if ActiveWindow.View = xlNormalView then
'use the normal ID
else
'use the pagebreak ID
end if

And if you use pivottables, you may have another commandbar to update, too.



martin.j.jung@googlemail.com wrote:
>

<<snipped>>
>
> Thanks for your answer ...
>
> I tried it and it worked but is there a way to get the current
> commandbar, irrespective what view I have?
> Meanwhile I have learned that I have to use even another commandbar,
> if in the cell that is under the cursor is attached to a query from a
> database...


--

Dave Peterson
Reply With Quote
  #6 (permalink)  
Old 09-04-2008, 07:36 PM
Jim Rech
 
Posts: n/a
Re: Adding Context Menu (right click) Options

You have to modify each commandbar that could popup in any context you want
to cover.

And I suggest that you do it when the workbook opens or is activated rather
than at the right-click event. The reason is that your modifications will
occur only if the user makes the menu popup by a right-click. But if he
uses some other means, like Shift-F10 or the dedicated context menu key that
some newer keyboards have, the right-click code will not be called and your
changes will not be there.

--
Jim
<martin.j.jung@googlemail.com> wrote in message
news:233aeb36-14c1-4ec3-a86b-2d8e081e2218@r15g2000prd.googlegroups.com...
On Sep 4, 6:54 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> I think that id number varied in different versions of excel.
>
> But (so far!), the pagebreak cell id was 3 more than the normal cell id.
>
>
>
>
>
> Bob Phillips wrote:
>
> > It too is called Cell, with an Id of 427 (as against the normal 424).

>
> > Do a Findcontrol on both by Id and add to each control.

>
> > --
> > __________________________________
> > HTH

>
> > Bob

>
> > <martin.j.j...@googlemail.com> wrote in message
> >news:42ccfff6-d4e7-4059-bf72-4de5abb92e7c@1g2000pre.googlegroups.com...
> > > Hello,

>
> > > I try to add a context menu to an excel sheet. The problem is that I
> > > can not identify the current commandbar as it seems that this
> > > commandbar is different wether you are in "normal view" or - and
> > > that
> > > is the problem here - you are in "page Break Preview". If the sheet
> > > is
> > > in the normal view the following code works fine, but not if I am in
> > > the "page Break Preview" Mode. I assume the commandbar will even
> > > change if I have a comment in the cell or not and so on ... Is there
> > > a
> > > way to identify the commandbar that will pop up after the
> > > "BeforeRightClick"-Event?

>
> > > At the moment I have to following code in my worksheet and it works
> > > fine during "normal view" but it does not work during "page Break
> > > Preview"

>
> > > Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
> > > As Boolean)
> > > On Error Resume Next
> > > cmdid = Application.CommandBars("Cell").ID
> > > ' cmdid = 427
> > > With Application
> > > .CommandBars(cmdid).Controls("Update Work Center in
> > > SAP").Delete
> > > Set cBut
> > > = .CommandBars(cmdid).Controls.Add(Temporary:=True)
> > > End With

>
> > > With cBut
> > > .Caption = "Update Work Center in SAP"
> > > .Style = msoButtonCaption
> > > .OnAction = "change_workcenter"
> > > .Parameter = Format(Target.value)
> > > End With
> > > On Error GoTo 0
> > > End Sub

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


Thanks for your answer ...

I tried it and it worked but is there a way to get the current
commandbar, irrespective what view I have?
Meanwhile I have learned that I have to use even another commandbar,
if in the cell that is under the cursor is attached to a query from a
database...

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:01 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Car Loan | Credit Card | Gas Suppliers | Myspace Layouts | MPAA



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114