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?
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: