After Chart Export OLE Server Error

mary.h

Registered User.
Local time
Today, 12:36
Joined
Aug 21, 2003
Messages
48
Hello,

with this little code, I am exporting a chart from a report to a gif-file. The code does not give any error, but after exporting the chart, when I am going to close the active report window the following error message appears and I can't close my application any more.

Errormessage:
"The operation on the OLE object (Chart) failed.
The OLE server may not be registered.
To register the OLE server please install it again"

My code:
Dim myRep As Report
Dim myChart As Graph.Chart

If Application.CurrentObjectType = acReport Then
Set myRep = Screen.ActiveReport
Set myChart = myRep.OLEUngebunden0.Object

myChart.Export FileName:=myRep.Caption & "_" & intBerichtsjahr & ".gif", FilterName:="GIF"

Set myChart = Nothing
Set myRep = Nothing
Else
Exit Function
End If

Can anybody help? I've deactivated script blocking in Norten as this is a common problem with OLE server but no change.

Thank you in advance for your assistance.
Kind regards,
Mary.h
 
Hi,

I found a solution in this MS article.

http://support.microsoft.com/default.aspx?scid=kb;en-us;287022

I just need to add the following line to my code:
Me.OLEUngebunden0.Action = acOLEClose

But their solution is based on a command button on a form. I have a menu button and just cant figure out how to "translate" the line
Me.OLEUngebunden0.Action = acOLEClose
into my object handling (I can't use Me)

I refer to what is Me as myRep but it's not working if I write
myRep.OLEUngebunden0.Action = acOLEClose.

I guess it's super easy for you.

Many thanks in advance.
Mary.h
 
Hi,

I've managed a workaround, as the main problem wasn't probably the object handling, but the OLE object can't be changed in report preview mode.

What I did was, change to design view and then close the object. I hided the action by using echo.

Kind regards
Mary.h

My Code:

Function ExportChart()
Dim myRep As Report
Dim myChart As Graph.Chart
Dim myRepName As String

On Error GoTo ExportChart_Err

If Application.CurrentObjectType = acReport Then
Set myRep = Screen.ActiveReport
Set myChart = myRep.OLEUngebunden0.Object
myRepName = myRep.Name
DoCmd.Hourglass True
Echo False
myChart.Export FileName:=myRep.Caption & "_" & intBerichtsjahr & ".gif", FilterName:="GIF"
DoCmd.OpenReport myRep.Name, acViewDesign
DoCmd.Close acReport, myRepName, acSaveNo

Set myChart = Nothing
Set myRep = Nothing
Else
Exit Function
End If

ExportChart_Exit:
Echo True
DoCmd.Hourglass False
Exit Function

ExportChart_Err:
MsgBox Error$
Resume ExportChart_Exit

End Function
 

Users who are viewing this thread

Back
Top Bottom