Microsoft Excel已停止仅在从VBA代码保存工作簿后才能工作 [英] Microsoft Excel Stopped Working only after saving the workbook from VBA code

查看:91
本文介绍了Microsoft Excel已停止仅在从VBA代码保存工作簿后才能工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这对许多人来说都是一个类似的问题,但并不完全匹配。 我有一个使用带有用户表单的VBA的Microsoft Excel应用程序。 在VBA代码中,工作簿在特定条件下保存。 我也有SUBs保存直接从工作表上的按钮运行的代码
。 这些SUB位于模块中。 我可以重新打开工作簿,但当我单击按钮加载用户窗体时,我得到了可怕的"Microsoft Excel已停止工作...."消息,它只是挂起
。 我必须杀掉Excel进程才能摆脱它。 如果我不从VBA中保存工作簿,它就可以正常工作。 另外,如果我等了一个小时左右,问题就会消失(垃圾收集?) 我尝试了几个"On Error"
语句,但它们不会捕获异常终止。 我很快就结束了。 请帮忙!

I see this is a similar problem to many, but not an exact match.  I have a Microsoft Excel application using VBA with a userform.  From within the VBA code, the workbook is saved under certain conditions.  I also have SUBs which save the code that run directly from a button on a worksheet.  Those SUBs reside in a module.  I can reopen the workbook fine, but when I click the button to load the userform, I get the dreaded "Microsoft Excel has stopped working...." message and it just hangs.  I have to kill the Excel process to get rid of it.  If I don't save the workbook from within VBA, it works just fine.  Also, if I wait an hour or so, the problem goes away (garbage collection?)  I tried several "On Error" statements, but they don't trap the abend.  I'm at wit's end.  Please help!

我在Windows 7上运行Microsoft Office 2013。

I'm running Microsoft Office 2013 on Windows 7.

推荐答案

您好
jwagner001,

您已经提到过,"工作簿在某些条件下保存"。

you have mentioned that ,"the workbook is saved under certain conditions".

但您没有提到条件。

你提到你有一个sub,你通过按钮调用了这个sub,它位于模块中。

you mentioned that you have a sub and you called this sub through button and it reside in module.

为什么不把你的代码放在按钮点击事件上。

why don't you place your code on buttons click event.

您提到的问题,当您点击按钮调用userform excel挂起时。

the issue you have mentioned that when you click on button to call userform excel hangs.

请尝试使用下面的代码打开用户表单上的按钮点击

please try to use code below to open user form on button click

Private Sub CommandButton2_Click()
UserForm1.Show
End Sub

如果仍然出现错误那么我建议你只尝试在新创建的excel中的按钮点击事件上打开用户表单文件。

if you still get error then I would recommend you to try only open a user form on button click event in newly created excel file.

这样我们就可以缩小这个问题。

so that we can narrow down this issue.

如果成功打开那么我认为问题出在您的代码上。

if it open successfully then I think that the problem is with your code.

请尝试提供您的演示代码,以便我们为您提供更多帮助。

please try to provide your demo code that reproduce this issue on our side so that we can help you further.

问候

Deepak


这篇关于Microsoft Excel已停止仅在从VBA代码保存工作簿后才能工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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