Posted this in the VBScript forum -- but no responses so far.
Any ideas appreciated.....
Trying to do some simple charting for an in-house site and I keep getting an error:
Error Type:
Microsoft Office Web Components 9.0 (0x800A03EC)
The file c:\inetpub\could not be opened for export.
/pinnacle/chartExample2.asp, line 11
Sorry for all the code - but just can't get this.
<code>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>Chart Example</TITLE>
<!-- #include virtual="/includes/adovbs.inc" -->
<%
Function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath)
Dim strFileName
Randomize
strFileName = Timer & Rnd & ".gif"
objCSpace.ExportPicture strAbsFilePath & "\" & strFileName, "gif", 600, 350
ExportChartToGIF = strRelFilePath & "/" & strFileName
End Function
Sub CleanUpGIF(GIFpath)
Dim objFS
Dim objFolder
Dim gif
set objFS = Server.CreateObject("Scripting.FileSystemObject"
set objFolder = objFS.GetFolder(GIFpath)
for each gif in objFolder.Files
if instr(gif.Name, ".gif" > 0 and DateDiff("n", gif.DateLastModified, now) > 10 then
objFS.DeleteFile GIFpath & "\" & gif.Name, True
end if
next
set objFolder = nothing
set objFS = nothing
End Sub
%>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<%
dim objChartSpace
dim objChart
dim objSeries
dim c
dim series
dim strChartAbsPath
strChartAbsPath = Server.MapPath("/pinnacle"
dim strChartRelPath
strChartRelPath = "temp"
dim strChartFile
set objChartSpace = Server.CreateObject("OWC.Chart"
set objChart = objChartSpace.Charts.Add()
set c = objChartSpace.Constants
objChart.Type = c.chChartTypeLineMarkers
objChart.HasLegend = True
'Database Connection & Recordset Creation
Dim objConn
set objConn = Server.CreateObject("ADODB.Connection"
objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
objConn.Properties("Data Source" = Server.MapPath("Databases/Pinnacle.mdb"
objConn.Open
Dim strSQL
strSQL = "SELECT * FROM chartExample"
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset"
objRS.Open strSQL, objConn, adOpenStatic
'Temp write out revenue data
Do While Not objRS.EOF
response.write objRS("revenue" & "<br>"
objRS.MoveNext
Loop
'response.end
set objChartSpace.DataSource = objRS
objChart.SetData c.chDimSeriesNames, 0, "month"
for each objSeries in objChart.SeriesCollection
objSeries.SetData c.chDimCategories, 0, "revenue"
objSeries.SetData c.chDimValues, 0, "profit"
next
'for each axis in objChart.Axes
' axis.HasTitle = True
' if axis.Type = c.chCategoryAxis then
' axis.Title.Caption = "Revenue"
' else
' axis.Title.Caption = "Profit"
' end if
'next
'objChart.SeriesCollection(2).Interior.Color = "red"
'objChart.SeriesCollection(2).Line.Color = "red"
strChartFile = ExportChartToGIF(objChartSpace, strChartAbsPath, strChartRelPath)
Response.Write "<IMG SRC=""" & strChartFile & """>" & "<P>"
CleanUpGIF strChartAbsPath
objRS.Close
set objRS = nothing
set objConn = nothing
set objSeries = nothing
set objChart = nothing
set objChartSpace = nothing
%>
</BODY>
</HTML>
</code>
Any ideas appreciated.....
Trying to do some simple charting for an in-house site and I keep getting an error:
Error Type:
Microsoft Office Web Components 9.0 (0x800A03EC)
The file c:\inetpub\could not be opened for export.
/pinnacle/chartExample2.asp, line 11
Sorry for all the code - but just can't get this.
<code>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>Chart Example</TITLE>
<!-- #include virtual="/includes/adovbs.inc" -->
<%
Function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath)
Dim strFileName
Randomize
strFileName = Timer & Rnd & ".gif"
objCSpace.ExportPicture strAbsFilePath & "\" & strFileName, "gif", 600, 350
ExportChartToGIF = strRelFilePath & "/" & strFileName
End Function
Sub CleanUpGIF(GIFpath)
Dim objFS
Dim objFolder
Dim gif
set objFS = Server.CreateObject("Scripting.FileSystemObject"
set objFolder = objFS.GetFolder(GIFpath)
for each gif in objFolder.Files
if instr(gif.Name, ".gif" > 0 and DateDiff("n", gif.DateLastModified, now) > 10 then
objFS.DeleteFile GIFpath & "\" & gif.Name, True
end if
next
set objFolder = nothing
set objFS = nothing
End Sub
%>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<%
dim objChartSpace
dim objChart
dim objSeries
dim c
dim series
dim strChartAbsPath
strChartAbsPath = Server.MapPath("/pinnacle"
dim strChartRelPath
strChartRelPath = "temp"
dim strChartFile
set objChartSpace = Server.CreateObject("OWC.Chart"
set objChart = objChartSpace.Charts.Add()
set c = objChartSpace.Constants
objChart.Type = c.chChartTypeLineMarkers
objChart.HasLegend = True
'Database Connection & Recordset Creation
Dim objConn
set objConn = Server.CreateObject("ADODB.Connection"
objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
objConn.Properties("Data Source" = Server.MapPath("Databases/Pinnacle.mdb"
objConn.Open
Dim strSQL
strSQL = "SELECT * FROM chartExample"
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset"
objRS.Open strSQL, objConn, adOpenStatic
'Temp write out revenue data
Do While Not objRS.EOF
response.write objRS("revenue" & "<br>"
objRS.MoveNext
Loop
'response.end
set objChartSpace.DataSource = objRS
objChart.SetData c.chDimSeriesNames, 0, "month"
for each objSeries in objChart.SeriesCollection
objSeries.SetData c.chDimCategories, 0, "revenue"
objSeries.SetData c.chDimValues, 0, "profit"
next
'for each axis in objChart.Axes
' axis.HasTitle = True
' if axis.Type = c.chCategoryAxis then
' axis.Title.Caption = "Revenue"
' else
' axis.Title.Caption = "Profit"
' end if
'next
'objChart.SeriesCollection(2).Interior.Color = "red"
'objChart.SeriesCollection(2).Line.Color = "red"
strChartFile = ExportChartToGIF(objChartSpace, strChartAbsPath, strChartRelPath)
Response.Write "<IMG SRC=""" & strChartFile & """>" & "<P>"
CleanUpGIF strChartAbsPath
objRS.Close
set objRS = nothing
set objConn = nothing
set objSeries = nothing
set objChart = nothing
set objChartSpace = nothing
%>
</BODY>
</HTML>
</code>