取消按钮Outlook用户窗体宏不会执行任何操作 [英] Cancel button outlook userform macro won't do anything

查看:76
本文介绍了取消按钮Outlook用户窗体宏不会执行任何操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整日忙于搜索,从2008年至2012年我发现Google不断返回的所有示例都无济于事,所以我想在这里尝试一下.

I've been googling around all day and all the examples I've found from 2008-2012 that Google keeps returning are not doing anything, so i figured I'd give it a try here.

我有一个带有用户窗体的Outlook宏,在用户窗体上有一个取消按钮.

I have an Outlook macro with a UserForm, and on the UserForm I have a cancel button.

Sub DialogTest()
    MyForm.Show
End Sub

Private Sub CancelButton_Click()
    Unload Me
    End
End Sub

我也尝试过MyForm.HideEnd本身,cmdExit_Click等,但它不会做任何事情.取消按钮不会关闭对话框,也不会导致调试器启动.

I've also tried MyForm.Hide, End by itself, cmdExit_Click etc etc it will not do anything. The cancel button does not close the dialog nor does it cause the debugger to come up.

是否有人在Outlook宏的VBA用户窗体上有一个简单的取消"按钮?

Is there anyone out there that has a simple working Cancel button on a VBA UserForm for Outlook macros?

推荐答案

只有将Unload Me Sub粘贴到工作表或模块中时,我才能复制您的问题.当Sub位于 Userform 中时,它可以正常工作.

I was only able to replicate your issue when the Unload Me Sub was pasted in a Worksheet or Module. When the Sub is in the Userform, it works fine.

在这里,代码粘贴在模块中,并且不会关闭用户窗体

Here, the code is pasted in a module and does not close the Userform

,双击您的用户窗体,然后双击您的取消"按钮.

Instead, from VBE, double click on your UserForm, then double click on your Cancel Button.

然后将代码粘贴到此处

这篇关于取消按钮Outlook用户窗体宏不会执行任何操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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