Solved

Excel Command Bar

Posted on 2015-01-13
3
125 Views
Last Modified: 2015-01-14
I want to add a few buttons to the command pop up
When running the code, the program exits before end sub
After the line:   bpItem.OnAction = "UploadData", The program exits


I have the following code:
Private Sub createPopup()
    Dim bpBar As CommandBar
    Dim bpItem As CommandBarControl
   
    On Error GoTo handle
   
    CommandBars("Cell").Controls("Upload").Delete
   
    Set bpBar = CommandBars("Cell")
    Set bpItem = bpBar.Controls.Add(Type:=msoControlButton)
   
    bpItem.Caption = "Upload"
    bpItem.FaceId = 38
    bpItem.OnAction = "UploadData"          'The program exits after this line
   
    Set bpItem = Nothing
   
    Set bpItem = bpBar.Controls.Add(Type:=msoControlButton)
   
    With bpItem
        .Caption = "Sort"
        .OnAction = "BPSort"
    End With
   
    Exit Sub

Is there a solution? thanks!
0
Comment
Question by:CABRLU63
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 40548515
Hi,

You handle the error so which error do you get?

and if   bpItem.FaceId = 0 do you get an error as well

Regards
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40548672
YOu might want to try the syntax:

bpItem.OnAction = "=UploadData()"

The OnAction argument is a bit finicky, but only in the way it works.  I've never had a problem setting the OnAction argument to just about anything, the button simply doesn't work if you get the syntax wrong.  So I'm not sure what would cause your code to fail at that point.
0
 

Author Comment

by:CABRLU63
ID: 40548892
Hi
Thanks for the answer
=UploadData() worked

I was not getting an error
The code simply discontinued
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question