Run sub every 2 seconds in a loop on excel form

phantomi_man

New Member
Joined
Jul 28, 2021
Messages
1
Office Version
  1. 2010
Hello,

I would like to know if there's a way to call a specific sub (like sub generate_list) that would constantly check if anything is happening on an excel form.

For example, currently if I enter something in a textbox, the sub
VBA Code:
sub textbox_afterupdate ()
will call a
VBA Code:
sub generate_html

like

VBA Code:
sub name_afterupdate ()
call generate_html
end sub


the generate_html sub generates a HTML file and then displays it in
VBA Code:
 WebBrowser1.Navigate filepath

like a html preview


The problem of course is that the textbox only updates when you move to the next textbox or click on the form. Which is fine. But that means the HTML preview isn't as instant as I would like (like showing the actual real time typing)

I could change the textbox event trigger as change


VBA Code:
sub name_change()
call generate_html
end sub


But the problem is that this is slow. Because if I do a keystroke it will call the
VBA Code:
sub generate_html
every time and complete the routine (generate HTML and display it) and only THEN it will show what is being typed in the text box. Like if someone would type something and the keyboard would hold the input for few seconds.

Basically every letter generates a preview. Which is what I want but I would like it seamlessly in the background - constantly refreshing and generating the preview.

Thank you


And i'm sorry I have not much code to show
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top