Solved

Excel Command Bar

Posted on 2015-01-13
3
121 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
3 Comments
 
LVL 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now