excel vba表单已closures,但无法切换到其他.xlsm工作簿

我有一个macros的工作簿“A”,并设置一个快捷键“Ctrl + Q”,当我按下“Ctrl + Q”popup一个窗体,当我按下“ESC”窗体closures,因为我添加了一个属性“取消”设置为TRUEbutton“CommandButton1”。

在代码中我像这样closures表单:

 Private Sub CommandButton1_Click() Unload Me End Sub 

它工作正常,但问题是我不能切换到其他打开的工作簿,直到我closures工作簿“A”,有没有人知道这是什么问题?

非常感谢!

代码是这样的:

 VERSION 5.00 Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Get_Photo Caption = "abc" ClientHeight = 3120 ClientLeft = 45 ClientTop = 435 ClientWidth = 4710 OleObjectBlob = "Get_Photo.frx":0000 StartUpPosition = 1 'CenterOwner End Attribute VB_Name = "Get_Photo" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub CommandButton1_Click() Unload Me End Sub Sub UserForm_Initialize() With Get_Photo .Caption = caption_Name .Width = 430 .Height = 270 End With With WebBrowser1 .Width = 540 .Height = 300 .Navigate ("www.google.com/images/logos/images_logo_lg.gif") End With End Sub 

上面的表单包含一个网页浏览器和一个取消button。 我在工作表中添加了一个button,当单击button时,macros代码Get_Photo.Show将显示一张图片。 但是当我按下“ESC”后closures表格,我不能切换到其他xlsm工作簿,但xlsx工作簿很好..

@SiddharthRout,我增加了更多的意见,重现这个问题 – 亚纶30分钟前

最后,我已经能够重现:)让我检查一下,然后回复你。 我无法切换到其他xlsm / xlsx工作簿。 它不断向我展示原始的工作簿。 Alt + Tab也拒绝工作。 如果按下commandbutton,则不会发生任何exception。 – Siddharth Rout 1分钟前编辑

我无法解释这种行为。 可能它是一个错误( 但是,我还没有看到它的任何文档 )。

这将解决您的问题。 ( 试验和testing

把这两行额外的代码放在你调用useeform的工作表的button代码中。

 Private Sub CommandButton1_Click() UserForm1.Show Application.ShowWindowsInTaskbar = False Application.ShowWindowsInTaskbar = True End Sub 

HTH

希德