织梦CMS - 轻松建站从此开始!

欧博ABG-会员注册-官网网址

欧博allbetPause / Resume a looped macro with a butto

时间:2026-01-16 00:16来源: 作者:admin 点击: 3 次
Hello, I have a macro that goes on loop until a boolean is reached. I would like to add a button to Pause/Resume it. I thought about adding a Boo

06-21-2023, 06:27 AM

Soraka

Soraka is offline

Registered User

Join Date   02-08-2023   Location   Germany   MS-Off Ver   365   Posts   80  

Pause / Resume a looped macro with a button

Hello,
I have a macro that goes on loop until a boolean is reached.
I would like to add a button to Pause/Resume it.

I thought about adding a Boolean, I declared it as, Public Pause As Boolean.
I created a button with simply:

Please Login or Register to view this content.

Then in my already existing macro that goes on loop, I added:

Please Login or Register to view this content.

With LabelEnd: just before EndSub.

So after trying this, my macro that goes on loop still works correctly, but the button to Pause it does not have any effect on it.
I thought I did it correctly.
What am I missing?

Reply With Quote

Register To Reply

06-21-2023, 06:42 AM

davesexcel

davesexcel is offline

Forum Moderator

davesexcel's Avatar

Join Date   02-19-2006   Location   Regina   MS-Off Ver   MS 365   Posts   13,531  

Re: Pause / Resume a looped macro with a button

I don't think you can run a separate macro while another is already running.

,
Xlorate.com, , YouYube Channel

Reply With Quote

Register To Reply

06-21-2023, 07:13 AM

ByteMarks

ByteMarks is offline

Forum Expert

ByteMarks's Avatar

Join Date   07-23-2018   Location   UK   MS-Off Ver   O365 32bit (Win 11)   Posts   3,486  

Re: Pause / Resume a looped macro with a button

In your loop, try adding DoEvents before checking the state of Pause.

Please Login or Register to view this content.

You can also shorten your Click code to one line

Please Login or Register to view this content.


I guess GoTo LabelEnd stops the routine, so one way to resume could be to have some sort of counter which is saved to a public variable. Then, when you resume it can start at the next iteration.

Last edited by ByteMarks; 06-21-2023 at 11:52 AM.

Reply With Quote

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2026-01-16 22:01 最后登录:2026-01-16 22:01
栏目列表
推荐内容