+ Reply to Thread
Results 1 to 7 of 7

Adding Button to Popup Control

  1. #1
    trooper665
    Guest

    Adding Button to Popup Control

    I am trying to add a button to a popup control, but I am getting an error
    message saying that the add method failed. Here is the code that I am using.
    This code works for other controls.

    Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    (Type:=msoControlPopup, Id:=30080, Before:=2)

    oPop.Caption = "Change IT!"
    'basic shapes------------------------------------------------

    Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup, Id:=1405,
    Before:=1)

    oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232

    Does anyone know what I am doing wrong?

    Thanks,
    Jeff


  2. #2
    Rob Bovey
    Guest

    Re: Adding Button to Popup Control

    Hi Jeff,

    You can't make any modifications to a built-in control of type
    msoControlButtonPopup.

    --
    Rob Bovey, Excel MVP
    Application Professionals
    http://www.appspro.com/

    * Take your Excel development skills to the next level.
    * Professional Excel Development
    http://www.appspro.com/Books/Books.htm

    "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    news:26309E73-0DD6-4466-8A51-796F2194DFD0@microsoft.com...
    >I am trying to add a button to a popup control, but I am getting an error
    > message saying that the add method failed. Here is the code that I am
    > using.
    > This code works for other controls.
    >
    > Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    > (Type:=msoControlPopup, Id:=30080, Before:=2)
    >
    > oPop.Caption = "Change IT!"
    > 'basic shapes------------------------------------------------
    >
    > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup, Id:=1405,
    > Before:=1)
    >
    > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232
    >
    > Does anyone know what I am doing wrong?
    >
    > Thanks,
    > Jeff
    >




  3. #3
    trooper665
    Guest

    Re: Adding Button to Popup Control

    But this very same code works:

    Set oPop =
    Application.CommandBars("BPT_BOTTOM").Controls.Add(Type:=msoControlPopup,
    Id:=30177, Before:=1)
    oPop.Caption = "Shapes!"
    'lines-------------------------------------------------------
    Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    Id:=2631, Before:=1)
    oSecondPop.Controls.Add Type:=msoControlButton, Id:=130, Before:=1
    oSecondPop.Controls.Add Type:=msoControlButton, Id:=243, Before:=2
    oSecondPop.Controls.Add Type:=msoControlButton, Id:=1639, Before:=3

    As far as I can tell the code is the exact same. Why does it work in one
    place, but not another?

    Thanks,
    Jeff

    "Rob Bovey" wrote:

    > Hi Jeff,
    >
    > You can't make any modifications to a built-in control of type
    > msoControlButtonPopup.
    >
    > --
    > Rob Bovey, Excel MVP
    > Application Professionals
    > http://www.appspro.com/
    >
    > * Take your Excel development skills to the next level.
    > * Professional Excel Development
    > http://www.appspro.com/Books/Books.htm
    >
    > "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    > news:26309E73-0DD6-4466-8A51-796F2194DFD0@microsoft.com...
    > >I am trying to add a button to a popup control, but I am getting an error
    > > message saying that the add method failed. Here is the code that I am
    > > using.
    > > This code works for other controls.
    > >
    > > Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    > > (Type:=msoControlPopup, Id:=30080, Before:=2)
    > >
    > > oPop.Caption = "Change IT!"
    > > 'basic shapes------------------------------------------------
    > >
    > > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup, Id:=1405,
    > > Before:=1)
    > >
    > > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232
    > >
    > > Does anyone know what I am doing wrong?
    > >
    > > Thanks,
    > > Jeff
    > >

    >
    >
    >


  4. #4
    Rob Bovey
    Guest

    Re: Adding Button to Popup Control

    Hi Jeff,

    After investigating this further it appears that I was wrong. I'm not
    sure what the problem is at this point, but it seems to have something to do
    with the control whose ID is 1232. I'm unable to add that control to
    anything. Which control does this ID refer to?

    --
    Rob Bovey, Excel MVP
    Application Professionals
    http://www.appspro.com/

    * Take your Excel development skills to the next level.
    * Professional Excel Development
    http://www.appspro.com/Books/Books.htm

    "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    news:9FF00A6B-6D38-4440-B2C2-50665821201F@microsoft.com...
    > But this very same code works:
    >
    > Set oPop =
    > Application.CommandBars("BPT_BOTTOM").Controls.Add(Type:=msoControlPopup,
    > Id:=30177, Before:=1)
    > oPop.Caption = "Shapes!"
    > 'lines-------------------------------------------------------
    > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    > Id:=2631, Before:=1)
    > oSecondPop.Controls.Add Type:=msoControlButton, Id:=130, Before:=1
    > oSecondPop.Controls.Add Type:=msoControlButton, Id:=243, Before:=2
    > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1639, Before:=3
    >
    > As far as I can tell the code is the exact same. Why does it work in one
    > place, but not another?
    >
    > Thanks,
    > Jeff
    >
    > "Rob Bovey" wrote:
    >
    >> Hi Jeff,
    >>
    >> You can't make any modifications to a built-in control of type
    >> msoControlButtonPopup.
    >>
    >> --
    >> Rob Bovey, Excel MVP
    >> Application Professionals
    >> http://www.appspro.com/
    >>
    >> * Take your Excel development skills to the next level.
    >> * Professional Excel Development
    >> http://www.appspro.com/Books/Books.htm
    >>
    >> "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    >> news:26309E73-0DD6-4466-8A51-796F2194DFD0@microsoft.com...
    >> >I am trying to add a button to a popup control, but I am getting an
    >> >error
    >> > message saying that the add method failed. Here is the code that I am
    >> > using.
    >> > This code works for other controls.
    >> >
    >> > Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    >> > (Type:=msoControlPopup, Id:=30080, Before:=2)
    >> >
    >> > oPop.Caption = "Change IT!"
    >> > 'basic shapes------------------------------------------------
    >> >
    >> > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    >> > Id:=1405,
    >> > Before:=1)
    >> >
    >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232
    >> >
    >> > Does anyone know what I am doing wrong?
    >> >
    >> > Thanks,
    >> > Jeff
    >> >

    >>
    >>
    >>




  5. #5
    trooper665
    Guest

    Re: Adding Button to Popup Control

    Hi Rob,

    This is the "change shape to rectangle control" from the Basic Shapes popup
    menu in the Change AutoShapes control. I hope that makes sense.

    Thanks,
    Jeff

    "Rob Bovey" wrote:

    > Hi Jeff,
    >
    > After investigating this further it appears that I was wrong. I'm not
    > sure what the problem is at this point, but it seems to have something to do
    > with the control whose ID is 1232. I'm unable to add that control to
    > anything. Which control does this ID refer to?
    >
    > --
    > Rob Bovey, Excel MVP
    > Application Professionals
    > http://www.appspro.com/
    >
    > * Take your Excel development skills to the next level.
    > * Professional Excel Development
    > http://www.appspro.com/Books/Books.htm
    >
    > "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    > news:9FF00A6B-6D38-4440-B2C2-50665821201F@microsoft.com...
    > > But this very same code works:
    > >
    > > Set oPop =
    > > Application.CommandBars("BPT_BOTTOM").Controls.Add(Type:=msoControlPopup,
    > > Id:=30177, Before:=1)
    > > oPop.Caption = "Shapes!"
    > > 'lines-------------------------------------------------------
    > > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    > > Id:=2631, Before:=1)
    > > oSecondPop.Controls.Add Type:=msoControlButton, Id:=130, Before:=1
    > > oSecondPop.Controls.Add Type:=msoControlButton, Id:=243, Before:=2
    > > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1639, Before:=3
    > >
    > > As far as I can tell the code is the exact same. Why does it work in one
    > > place, but not another?
    > >
    > > Thanks,
    > > Jeff
    > >
    > > "Rob Bovey" wrote:
    > >
    > >> Hi Jeff,
    > >>
    > >> You can't make any modifications to a built-in control of type
    > >> msoControlButtonPopup.
    > >>
    > >> --
    > >> Rob Bovey, Excel MVP
    > >> Application Professionals
    > >> http://www.appspro.com/
    > >>
    > >> * Take your Excel development skills to the next level.
    > >> * Professional Excel Development
    > >> http://www.appspro.com/Books/Books.htm
    > >>
    > >> "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    > >> news:26309E73-0DD6-4466-8A51-796F2194DFD0@microsoft.com...
    > >> >I am trying to add a button to a popup control, but I am getting an
    > >> >error
    > >> > message saying that the add method failed. Here is the code that I am
    > >> > using.
    > >> > This code works for other controls.
    > >> >
    > >> > Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    > >> > (Type:=msoControlPopup, Id:=30080, Before:=2)
    > >> >
    > >> > oPop.Caption = "Change IT!"
    > >> > 'basic shapes------------------------------------------------
    > >> >
    > >> > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    > >> > Id:=1405,
    > >> > Before:=1)
    > >> >
    > >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232
    > >> >
    > >> > Does anyone know what I am doing wrong?
    > >> >
    > >> > Thanks,
    > >> > Jeff
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >


  6. #6
    Rob Bovey
    Guest

    Re: Adding Button to Popup Control

    Hi Jeff,

    I'm not really sure what's different about the AutoShapes sub-controls
    that allows you to add identical versions of built-in controls to them where
    the sub-controls of the Change AutoShape menu don't.

    Even in the example where you modified the AutoShape Line menu, though,
    this doesn't seem to really do anything. If you press one version of the
    button, both versions depress, and if you tear off the Line menu, all of the
    duplicate controls disappear. I suspect it's just a quirk that the
    AutoShapes sub-controls allow this and it probably wasn't really meant to be
    supported.

    --
    Rob Bovey, Excel MVP
    Application Professionals
    http://www.appspro.com/

    * Take your Excel development skills to the next level.
    * Professional Excel Development
    http://www.appspro.com/Books/Books.htm

    "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    news:95EFAEE5-207C-4942-ADCC-D59F450F8359@microsoft.com...
    > Hi Rob,
    >
    > This is the "change shape to rectangle control" from the Basic Shapes
    > popup
    > menu in the Change AutoShapes control. I hope that makes sense.
    >
    > Thanks,
    > Jeff
    >
    > "Rob Bovey" wrote:
    >
    >> Hi Jeff,
    >>
    >> After investigating this further it appears that I was wrong. I'm not
    >> sure what the problem is at this point, but it seems to have something to
    >> do
    >> with the control whose ID is 1232. I'm unable to add that control to
    >> anything. Which control does this ID refer to?
    >>
    >> --
    >> Rob Bovey, Excel MVP
    >> Application Professionals
    >> http://www.appspro.com/
    >>
    >> * Take your Excel development skills to the next level.
    >> * Professional Excel Development
    >> http://www.appspro.com/Books/Books.htm
    >>
    >> "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    >> news:9FF00A6B-6D38-4440-B2C2-50665821201F@microsoft.com...
    >> > But this very same code works:
    >> >
    >> > Set oPop =
    >> > Application.CommandBars("BPT_BOTTOM").Controls.Add(Type:=msoControlPopup,
    >> > Id:=30177, Before:=1)
    >> > oPop.Caption = "Shapes!"
    >> > 'lines-------------------------------------------------------
    >> > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    >> > Id:=2631, Before:=1)
    >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=130, Before:=1
    >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=243, Before:=2
    >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1639, Before:=3
    >> >
    >> > As far as I can tell the code is the exact same. Why does it work in
    >> > one
    >> > place, but not another?
    >> >
    >> > Thanks,
    >> > Jeff
    >> >
    >> > "Rob Bovey" wrote:
    >> >
    >> >> Hi Jeff,
    >> >>
    >> >> You can't make any modifications to a built-in control of type
    >> >> msoControlButtonPopup.
    >> >>
    >> >> --
    >> >> Rob Bovey, Excel MVP
    >> >> Application Professionals
    >> >> http://www.appspro.com/
    >> >>
    >> >> * Take your Excel development skills to the next level.
    >> >> * Professional Excel Development
    >> >> http://www.appspro.com/Books/Books.htm
    >> >>
    >> >> "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    >> >> news:26309E73-0DD6-4466-8A51-796F2194DFD0@microsoft.com...
    >> >> >I am trying to add a button to a popup control, but I am getting an
    >> >> >error
    >> >> > message saying that the add method failed. Here is the code that I
    >> >> > am
    >> >> > using.
    >> >> > This code works for other controls.
    >> >> >
    >> >> > Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    >> >> > (Type:=msoControlPopup, Id:=30080, Before:=2)
    >> >> >
    >> >> > oPop.Caption = "Change IT!"
    >> >> > 'basic shapes------------------------------------------------
    >> >> >
    >> >> > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    >> >> > Id:=1405,
    >> >> > Before:=1)
    >> >> >
    >> >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232
    >> >> >
    >> >> > Does anyone know what I am doing wrong?
    >> >> >
    >> >> > Thanks,
    >> >> > Jeff
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>




  7. #7
    trooper665
    Guest

    Re: Adding Button to Popup Control

    Hi Rob,

    Thanks for the answer. The goal of the macro was to set up every user's
    PowerPoint with the same buttons and controls. Hopefully, they will be able
    to get by without the change autoshapes (or at least add it on their own).

    That seems odd that the AutoShapes control works, but the Change AutoShapes
    doesn't. Perhaps it has something to do with the control dynamically
    enabling and disabling depending on whether the user has selected an object.

    Thanks for your help,
    Jeff

    "Rob Bovey" wrote:

    > Hi Jeff,
    >
    > I'm not really sure what's different about the AutoShapes sub-controls
    > that allows you to add identical versions of built-in controls to them where
    > the sub-controls of the Change AutoShape menu don't.
    >
    > Even in the example where you modified the AutoShape Line menu, though,
    > this doesn't seem to really do anything. If you press one version of the
    > button, both versions depress, and if you tear off the Line menu, all of the
    > duplicate controls disappear. I suspect it's just a quirk that the
    > AutoShapes sub-controls allow this and it probably wasn't really meant to be
    > supported.
    >
    > --
    > Rob Bovey, Excel MVP
    > Application Professionals
    > http://www.appspro.com/
    >
    > * Take your Excel development skills to the next level.
    > * Professional Excel Development
    > http://www.appspro.com/Books/Books.htm
    >
    > "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    > news:95EFAEE5-207C-4942-ADCC-D59F450F8359@microsoft.com...
    > > Hi Rob,
    > >
    > > This is the "change shape to rectangle control" from the Basic Shapes
    > > popup
    > > menu in the Change AutoShapes control. I hope that makes sense.
    > >
    > > Thanks,
    > > Jeff
    > >
    > > "Rob Bovey" wrote:
    > >
    > >> Hi Jeff,
    > >>
    > >> After investigating this further it appears that I was wrong. I'm not
    > >> sure what the problem is at this point, but it seems to have something to
    > >> do
    > >> with the control whose ID is 1232. I'm unable to add that control to
    > >> anything. Which control does this ID refer to?
    > >>
    > >> --
    > >> Rob Bovey, Excel MVP
    > >> Application Professionals
    > >> http://www.appspro.com/
    > >>
    > >> * Take your Excel development skills to the next level.
    > >> * Professional Excel Development
    > >> http://www.appspro.com/Books/Books.htm
    > >>
    > >> "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    > >> news:9FF00A6B-6D38-4440-B2C2-50665821201F@microsoft.com...
    > >> > But this very same code works:
    > >> >
    > >> > Set oPop =
    > >> > Application.CommandBars("BPT_BOTTOM").Controls.Add(Type:=msoControlPopup,
    > >> > Id:=30177, Before:=1)
    > >> > oPop.Caption = "Shapes!"
    > >> > 'lines-------------------------------------------------------
    > >> > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    > >> > Id:=2631, Before:=1)
    > >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=130, Before:=1
    > >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=243, Before:=2
    > >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1639, Before:=3
    > >> >
    > >> > As far as I can tell the code is the exact same. Why does it work in
    > >> > one
    > >> > place, but not another?
    > >> >
    > >> > Thanks,
    > >> > Jeff
    > >> >
    > >> > "Rob Bovey" wrote:
    > >> >
    > >> >> Hi Jeff,
    > >> >>
    > >> >> You can't make any modifications to a built-in control of type
    > >> >> msoControlButtonPopup.
    > >> >>
    > >> >> --
    > >> >> Rob Bovey, Excel MVP
    > >> >> Application Professionals
    > >> >> http://www.appspro.com/
    > >> >>
    > >> >> * Take your Excel development skills to the next level.
    > >> >> * Professional Excel Development
    > >> >> http://www.appspro.com/Books/Books.htm
    > >> >>
    > >> >> "trooper665" <trooper665@discussions.microsoft.com> wrote in message
    > >> >> news:26309E73-0DD6-4466-8A51-796F2194DFD0@microsoft.com...
    > >> >> >I am trying to add a button to a popup control, but I am getting an
    > >> >> >error
    > >> >> > message saying that the add method failed. Here is the code that I
    > >> >> > am
    > >> >> > using.
    > >> >> > This code works for other controls.
    > >> >> >
    > >> >> > Set oPop = Application.CommandBars("BPT_BOTTOM").Controls.Add
    > >> >> > (Type:=msoControlPopup, Id:=30080, Before:=2)
    > >> >> >
    > >> >> > oPop.Caption = "Change IT!"
    > >> >> > 'basic shapes------------------------------------------------
    > >> >> >
    > >> >> > Set oSecondPop = oPop.Controls.Add(Type:=msoControlButtonPopup,
    > >> >> > Id:=1405,
    > >> >> > Before:=1)
    > >> >> >
    > >> >> > oSecondPop.Controls.Add Type:=msoControlButton, Id:=1232
    > >> >> >
    > >> >> > Does anyone know what I am doing wrong?
    > >> >> >
    > >> >> > Thanks,
    > >> >> > Jeff
    > >> >> >
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1