A
AaronWestcott via AccessMonster.com
Hello all,
I am trying to export graphs in several reports to bmp. I have the following
code that works fine for both gif and jpeg but I get an "application-defined
or object-defined error" when I change to bmp and of course bmp is the format
requested by those who I am doing this for.
Any ideas would be appreciated.
Below code to populate graph datasheet and export (shamelessly taken from a
post on this site)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim rs As DAO.Recordset
Dim strSql As String
strSql = "SELECT [YEAR],[VMT] FROM [NYSVMT_qry]"
Set rs = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)
FillDataSheet Me.Graph77.Object, rs
rs.Close
Set rs = Nothing
End Sub
Public Sub FillDataSheet(GraphObject As Object, rs As DAO.Recordset)
Dim oSheet As Object 'Graph.DataSheet
Dim r As Integer 'row counter
Dim c As Integer 'column counter
Set oSheet = GraphObject.Application.DataSheet
'clear old data
oSheet.Cells.ClearContents
'1st Row Field Names = Legend entries
For c = 1 To rs.Fields.Count
oSheet.Cells(1, c) = rs(c - 1).Name
Next
'now data rows
r = 2
Do Until rs.EOF
For c = 1 To rs.Fields.Count
oSheet.Cells(r, c) = rs(c - 1).Value
Next
r = r + 1
rs.MoveNext
Loop
GraphObject.Application.Chart.Refresh
GraphObject.Application.Update
Set oSheet = Nothing
'***************************************
GraphObject.Export Filename:="c:\newimage.jpg", filtername:="jpg"
'***************************************
End Sub
I am trying to export graphs in several reports to bmp. I have the following
code that works fine for both gif and jpeg but I get an "application-defined
or object-defined error" when I change to bmp and of course bmp is the format
requested by those who I am doing this for.
Any ideas would be appreciated.
Below code to populate graph datasheet and export (shamelessly taken from a
post on this site)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim rs As DAO.Recordset
Dim strSql As String
strSql = "SELECT [YEAR],[VMT] FROM [NYSVMT_qry]"
Set rs = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)
FillDataSheet Me.Graph77.Object, rs
rs.Close
Set rs = Nothing
End Sub
Public Sub FillDataSheet(GraphObject As Object, rs As DAO.Recordset)
Dim oSheet As Object 'Graph.DataSheet
Dim r As Integer 'row counter
Dim c As Integer 'column counter
Set oSheet = GraphObject.Application.DataSheet
'clear old data
oSheet.Cells.ClearContents
'1st Row Field Names = Legend entries
For c = 1 To rs.Fields.Count
oSheet.Cells(1, c) = rs(c - 1).Name
Next
'now data rows
r = 2
Do Until rs.EOF
For c = 1 To rs.Fields.Count
oSheet.Cells(r, c) = rs(c - 1).Value
Next
r = r + 1
rs.MoveNext
Loop
GraphObject.Application.Chart.Refresh
GraphObject.Application.Update
Set oSheet = Nothing
'***************************************
GraphObject.Export Filename:="c:\newimage.jpg", filtername:="jpg"
'***************************************
End Sub