Save graph as jpeg (1 Viewer)

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
hi.
I need some help with my database. here the problem:

1. I can't save all the graph for all record (StnName) by one click button cmd2PS01.

here the code
Code:
Private Sub cmd2PS01_Click()
Dim objChart As Object
Dim strDate As String
Dim strFolder As String
strDate = Format(Now(), "dd mmmm yyyy")
strFolder = "StnInfo" & " (" & strDate & ")"
MkDir (CurrentProject.Path & "\" & strFolder)
Set objChart = Me.Graph8.Object
Me.Graph8.Object.Export Filename:=(CurrentProject.Path & "\" & strFolder) & "\" & "GraphDO (" & StnName & ")" & ".jpg"
Me.Graph8.Locked = False
Me.Graph8.Enabled = True
Set objChart = Nothing
DoCmd.Close acForm, "Form1", acSaveNo
DoEvents
End Sub

2. After i click the button, this error come out :
The operation on the Chart object failed.

The OLE server may not be registered.

To register the OLE server, reinstall it.

here I attach with the database.... can some one help me.!!!! please!!!
View attachment Save Graph As Jpeg.zip
 

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
ok thank... i will take a look.
how about to save all graph for every data just by one click?
 

DCrake

Remembered
Local time
Today, 22:57
Joined
Jun 8, 2005
Messages
8,632
I think you need to get it working for one before you embark on something more sophisticated.
 

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
Hi.
I'm already follow the instruction in http://support.microsoft.com/kb/824276.
and this is my new code for new button :

Code:
Private Sub Command6_Click()
Dim grpApp As Graph.Chart
strDate = Format(Now(), "dd mmmm yyyy")
strFolder = "StnInfo" & " (" & strDate & ")"
MkDir (CurrentProject.Path & "\" & strFolder)
Set grpApp = Me.Graph8.Object
grpApp.Export (CurrentProject.Path & "\" & strFolder) & "\" & "GraphDO (" & StnName & ")" & ".jpg"
Set grpApp = Nothing
Me.Graph8.Action = acOLEClose
End Sub

But the problem still same. is there any wrong with my code or i missing something?

please!!! need help.
here i attach a new db.

View attachment Save Graph As Jpeg.zip
 

vbaInet

AWF VIP
Local time
Today, 22:57
Joined
Jan 22, 2010
Messages
26,374
Code:
grpApp.Export (CurrentProject.Path & "\" & strFolder) & "\" & "GraphDO (" & StnName & ")" & ".jpg", [COLOR=Red]"JPEG"
See above. You missed something.
[/COLOR]
 

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
Hi. vbaInet.

I put the code as u suggestion
Code:
Private Sub Command6_Click()
Dim grpApp As Graph.Chart
strDate = Format(Now(), "dd mmmm yyyy")
strFolder = "StnInfo" & " (" & strDate & ")"
MkDir (CurrentProject.Path & "\" & strFolder)
Set grpApp = Me.Graph8.Object
grpApp.Export (CurrentProject.Path & "\" & strFolder) & "\" & "GraphDO (" & StnName & ")" & ".jpg", "JPEG"
Set grpApp = Nothing
Me.Graph8.Action = acOLEClose
End Sub
and then it come out with this error :
Code:
Run-time error '2793' :

Microsoft Office Access can't perform the operation specified in the Action 
property of the Visual Basic procedure you're trying to run.

then this error
Code:
The operation on the Chart object failed.

The OLE server may not be registered.

To register the OLE server, reinstall it.
 

vbaInet

AWF VIP
Local time
Today, 22:57
Joined
Jan 22, 2010
Messages
26,374
You never point to where the error is showing.
 

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
sorry vbaInet, I'm not expert in this (still learning).
i also don't know where the error. that's why i attach the database.

hopefully someone can look the attachment db and look for the error...... then help me solve it.
 

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
hi.. its OK everyone.
I already solve the problem. at the graph8 properties i should put yes for enabled.

now only left 1 problem. how to save all graph for all record just by one click.

here the attachment :
View attachment Save Graph As Jpeg (edit).zip
 

vbaInet

AWF VIP
Local time
Today, 22:57
Joined
Jan 22, 2010
Messages
26,374
This is looking very much like an assignment.

Loop through the recordset and export for every one. That's the best I can do :)
 

rio

Registered User.
Local time
Tomorrow, 05:57
Joined
Jun 3, 2008
Messages
124
hi.
can u more specific. as a beginner a can't catch what u mean.
or u can give an example or code or anything that can make me more understand.

thank for ur help.
 

Users who are viewing this thread

Top Bottom