Chart form error

KenHigg

Registered User
Local time
Today, 15:27
Joined
Jun 9, 2004
Messages
13,327
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?
 

Attachments

  • ChartTest.zip
    ChartTest.zip
    74.9 KB · Views: 112
  • error.gif
    error.gif
    6.7 KB · Views: 113
Thanks Adam. Did you open the database, run the code by pushing the button then close the form?
 
Nah. It happens on my laptop as well...

Thanks anyway.

Edit: This really has me frustrated...
 
Try adding after your export:

Code:
me.graph0.action = acoleclose
 
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...
 
Hum... When I do the acoleclose it screws up the chart...?!?
 
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...

Code:
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
 

Users who are viewing this thread

Back
Top Bottom