Solved

Excel Command Bar

Posted on 2015-01-13
3
118 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 48

Expert Comment

by:Rgonzo1971
Comment Utility
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
Comment Utility
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
Comment Utility
Hi
Thanks for the answer
=UploadData() worked

I was not getting an error
The code simply discontinued
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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