在Excel VBA的ActiveX按钮更新说明 [英] Updating caption on ActiveX button in Excel vba

查看:315
本文介绍了在Excel VBA的ActiveX按钮更新说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更新ActiveX控件按钮的标题在Excel US preadsheet要注意与点击事件相关联的code正在工作。在code从Azure数据库中提取数据,以便pressing按钮从5-10秒的延迟任何地方触发。

I'm trying to update the caption of an ActiveX control button on an Excel spreadsheet to note that the code associated with the click event is working. The code pulls data from an azure database so pressing the button triggers anywhere from a 5-10 sec delay.

我原来的code的,基本上看起来像这样的单个子:

My original code had a single sub that essentially looked like this:

Sub GetInfofromDB()
  btnUpdate.Caption = "Updating...."
  <<code to get data from azure db>>
  btnUpdate.Caption = "Update List" 'reverts button to standard text
End Sub

不过按钮标题不会改变。该组合框的更新工作。

However the button caption never changes. The combobox update works.

我分开的标题更新到自己的子然后叫每个子为了当按钮被pressed并得到了相同的行为,没有按钮更新。

I separated the caption update into its own sub and then called each sub in order when the button was pressed and got the same behavior, no button update.

如果我打电话的标题更新子,而不调用数据更新成功按钮更新。

If I call the sub with the caption update without calling the data update the button updates successfully.

所以,每一部分工作自身而不是当他们连续发生。想法如何让我的按钮之前的数据呼叫更新?

So, each part works on its own but not when they happen serially. Ideas how to get my button to update prior to the data call?

感谢。标记

推荐答案

尝试添加aaplication.screenupdating = true更改标题后。

Try adding a aaplication.screenupdating = true after changing the caption.

下面code为我工作。使用的DoEvents

the below code worked for me. Use a DoEvents

Private Sub CommandButton1_Click()
CommandButton1.Caption = "true"
DoEvents
Application.ScreenUpdating = True

For i = 1 To 2
    Application.Wait (Now + TimeValue("0:00:1"))
Next i

CommandButton1.Caption = "False"
End Sub

这篇关于在Excel VBA的ActiveX按钮更新说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆