Exporting Charts of Access to Image Format?

浪子不回头ぞ 提交于 2020-01-01 16:33:33

问题


I have created a chart in Access forms and exported it in Image Format. It's easily done, but the problem comes when after it, when I close the Form, It Shows a Pop-up message.

"The operation on the Chart object failed.
The OLE server may not be registered.
To register the OLE server, reinstall it. "

Then I have done some change and the Code looks Like:

Private Sub Command1_Click()     
  Dim grpApp As Graph.Chart 

  Set grpApp = Me.Graph1.Object     
  grpApp.Export "C:\Graph1.jpg", "JPEG"     
  Me.Graph1.Enabled = True    
  Me.Graph1.Locked = False    
  Set grpApp = Nothing     
  Me.Graph1.Action = acOLEClose     
End Sub

Now the problem is that after the export is done, the chart becomes bad, the fonts were big and condensed and the bars looked short...

I'm really stuck..


回答1:


After trying various workarounds, I found pretty much the same question and a proper fix for the problem:

  • Try unlocking the graph before the export, and restore the lock afterwards
'Unlock the control...
Me!YourOLEChart.Locked = False
Me!YourOLEChart.Enabled = True

'Do the actual export...
Set oleGrf = Me!YourOLEChart.Object
oleGrf.Export filename, "JPEG"
Set oleGrf = Nothing
Me!YourOLEChart.Action = acOLEClose

'Restore the lock...
Me!YourOLEChart.Locked = True
Me!YourOLEChart.Enabled = False
  • Important: remember to set the Action acOLEClose to avoid the OLE server from crashing.

You are not alone—I had the same problem. On several runs of the form, after the export execution, the chart/graph/OLEFrame became wrong (on the form View), its format got changed and I hadn't known why.



来源:https://stackoverflow.com/questions/1262698/exporting-charts-of-access-to-image-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!