Sub MakeCSSCols()
' Create an iFrame containing simple chart with vertical columns
Dim cHeight As Integer, cWidth As Integer, cColour As String
Dim cScaleMax As Integer, cScaleMin As Integer, cFileName As String
Dim MyDb As Database, MySet As Recordset
Set MyDb = CurrentDb()
Set MySet = MyDb.OpenRecordset("ChartCSSDataA")
cHeight = 150 ' height in pixels of main chart area
cWidth = 300
cColour = "#C7F1C7" ' colour of bars / cols
cScaleMax = 50
cScaleMin = 0
cFileName = "C:\SiteOct02\MyCSSChart1.htm"
Open cFileName For Output As #1 ' open a new text file - the HTML page
Print #1, "<style type='text/css'>"
Print #1, "body {font-family: Arial, Helvetica;font-size: 11pt;
margin-left:10px; margin-right: 40px; margin-top: 10px}"
Print #1, "td.full {padding: 2pt 0pt 0pt 0pt; border-style: transparent;
border:0px; font-family: Arial, Helvetica;font-size: 12pt;}"
Print #1, "div.verticbar {float: left; padding: 0px; width: 90%; height:
100%; margin: 2px; border: 1px solid rgba(0, 0, 0, .2);
background-color: " & cColour & ";}"
Print #1, "</style>"
Print #1, "<table style='width: " & Str(cWidth) & "px; border-collapse:
collapse; font-size:x-small;'>"
Print #1, " <tr style='height: " & Str(cHeight) & "px'
valign='bottom'><td>"
Print #1, " <table style='height: " & Str(cHeight - 10) & "px;
font-size:x-small; color:green'>"
Print #1, " <tr><td class='full' valign='Top'>" & Str(cScaleMax) &
"</td></tr>"
Print #1, " <tr><td class='full' valign='Middle'>" & Format((cScaleMax -
cScaleMin) / 2, "0") & "</td></tr>"
Print #1, " <tr><td class='full' valign='Bottom'>" & Str(cScaleMin) &
"</td></tr>"
Print #1, " </table></td>"
MySet.MoveFirst
Do Until MySet.EOF ' loop through the query records -------------------
Print #1, "<td class='full'><div class='verticbar' style='height:" &
Format(MySet!dvalue / (cScaleMax - cScaleMin) * cHeight, "0") & "px'
title='" & MySet!dtitle & "'></div></td>"
MySet.MoveNext
Loop
Print #1, " </tr><tr style='text-align:center'><td> </td>"
MySet.MoveFirst
Do Until MySet.EOF ' loop againh through the query records
-----------------
Print #1, "<td class='full'>" & MySet!dlabel & "</td>"
MySet.MoveNext
Loop
Print #1, "</tr></table>"
Print #1, "<p><span style='font-size: xx-small; color:gray'> Chart
source - iFrame(MyCSSChart2.htm) created by VBA Sub
MakeCSSCols()</span></p>"
Close #1
MySet.Close
MyDb.Close
Debug.Print Time(), "MakeCSSCols()", cFileName
End Sub
|