暂停VBA宏,允许用户进行选择,然后从中断处重新开始 [英] Pause VBA macro, allow user to make a selection, and restart where it left off

查看:594
本文介绍了暂停VBA宏,允许用户进行选择,然后从中断处重新开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想允许用户进行选择,运行一些代码,暂停其他选择,运行更多代码吗?

I want to allow the user to make a selection, run some code, pause for another selection, run more code?

我处理包含大量表的文档,这些表最终会转换为HTML.有时,两个类似表的格式不会转换相同的格式.了解转换器的工作原理后,我想从一个表中复制所有格式数据并将其粘贴"到另一个表中.

I work with documents with large number of tables that eventually convert to HTML. Sometimes the formatting on two like tables doesn't convert the same. Knowing how the converter works, I'd like to copy all of the formatting data from one table and "paste" it onto another one.

我的想法是让用户选择某项内容,点击复制按钮,选择其他内容然后点击粘贴按钮.

I've the idea of a userform to have the user select something, hit a copy button, select something else and hit a paste button.

推荐答案

使用计时器函数可以执行此操作.它可能不是最好的编码方式,但可以解决您的问题:

The timer function allows you to do this. It may not be the best way to code, but it is the answer to your problem:

'1st code here
Start = Timer
Do While Timer < Start + 10
  DoEvents
Loop
'do 2nd code here

DoEvents允许用户选择文本等.10秒钟后,代码从第二个代码"恢复.

DoEvents allows the user to select text, etc. After 10 seconds, the code resumes at "2nd code."

这篇关于暂停VBA宏,允许用户进行选择,然后从中断处重新开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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