?
Solved

Excel Command Bar

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

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 48

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

718 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