KenHigg
10-21-2008, 04:02 AM
In the attached db, after I save the chart the close the form I get the error message attached - Any ideas? I have set all the references I think I need...
I'm stumped as it happens on any of the machines I try it on. Maybe I need to set a property somewhere? Or maybe put another line of code in after I save the chart as an image?
ajetrumpet
10-21-2008, 04:42 AM
I've seen a huge amount of posts on this error Ken, but I only know of one solution because I've never had the problem myself. Take a look at this:
http://support.microsoft.com/kb/896865
It may be connected to your error perhaps.
<edit>
Or perhaps this one is too:
http://support.microsoft.com/default.aspx?scid=kb;en-us;313260
KenHigg
10-21-2008, 05:13 AM
Thanks Adam. Did you open the database, run the code by pushing the button then close the form?
KenHigg
10-21-2008, 07:56 AM
Nah. It happens on my laptop as well...
Thanks anyway.
Edit: This really has me frustrated...
chergh
10-21-2008, 08:56 AM
Try adding after your export:
me.graph0.action = acoleclose
KenHigg
10-21-2008, 09:17 AM
Whew - !!
Thanks chergh! I found that about the same time you posted it and it works. I've been beating my head against the wall for two days on this one. I thought I looked at all of the objects methods but I must have missed that one...
KenHigg
10-22-2008, 05:14 AM
Hum... When I do the acoleclose it screws up the chart...?!?
KenHigg
10-22-2008, 06:34 AM
Ok... I have a work around for this. I think to over come the original error message where it was telling me to register the ole server I needed to re-install the program that was set up to open the graphic file. But since I don't have admin rights to this machine that was not an option. Plus I don't want to have to deal with that error if the routine is run on other machines. So after the code export code runs I close the ole object. This however screws up the chart. So I copy the chart to the clipboard, do the export, close the object and then paste the chart back. This seems to work fine...
Public Function fncEmailChart_01(strFormName As String, strChartName As String)
'Save jpg part
Dim objChart As Chart
Set objChart = Forms(strFormName)(strChartName).Object
Forms(strFormName)(strChartName).Action = acOLECopy
objChart.Export FileName:="c:\localfiles\temp_email.gif"
Forms(strFormName)(strChartName).Action = acOLEClose
Set objChart = Nothing
Forms(strFormName)(strChartName).Action = acOLEPaste
DoEvents
'Send email part
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.Attachments.Add "c:\localfiles\temp_email.gif"
.To = "340364"
.Subject = "Test"
.HTMLBody = "<html><p>Sales Results</p>" & "<img src='cid:temp_email.gif'>"
.Display
End With
Set appOutLook = Nothing
Set MailOutLook = Nothing
End Function