clash aviodance code html refresh and page update

dantheman9

Board Regular
Joined
Feb 5, 2011
Messages
175
Hi I have some vba code which runs every 7 mintues to update tables in excel via text files, the code then also forms a html page which can be shown in powerpoint to scroll infomation.

In order to update information Im currently using a page refresh tag in the html page (I have 0 knowledge of databases so can't use that as an option).

It seems to work ok, except that sometimes the page refresh will occur when vba is updating the page, and so locks out access to the html refresh - so breaks the cycle.

Therefore i have been trying to come up with some code that will set the refresh time outside the vba refresh point.

I have come up with the following, but not 100% sure if it would work and if I have the IF statment correct - could I ask if someone to take 5 mins to take a look and see if they think it is right, and there thoughts on if this will work?


Code:
Info
 
cellhtml is the number of lines to process into the hmtl table (the bottom line number from the sheet with tables (Public As Integer)
Timerun is a (Public As Date) from the vba update event time (ie very 7 mins)
ctime function value return is refresh/86400 to get value from seconds to time (then converted to "00:00:00")
 
Dim currtime As Date
Dim refresh As Long
Dim stime As Variant
Dim st As String
Const slocal As String = "00:01:00"
 
' set refresh to 6 time value of lines to show
refresh = cellhtml * 6
 
'convert refresh time from seconds to time value via ctime function
stime = ctime(refresh)
 
'format to time value to process in IF below
st = Format(stime, "hh:mm:ss")
 
'work out when the html page will refresh from system time now and adding refresh time
currtime = Now() + TimeValue(st)
 
'see if refresh time is within 1 min of running table update, and if so add time to refresh to avoid clash
If Timerun = currtime > Timerun + TimeValue(slocal) And currtime < Timerun - TimeValue(slocal) Then
refresh = refresh + 130
End If
 
'set st to refresh value in html meta refresh tag
st = refresh
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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