Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel Command Bar

Posted on 2015-01-13
3
Medium Priority
?
129 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 53

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 49

Accepted Solution

by:
Dale Fye earned 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

886 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