Run-time error '1004'

C

Chris

Dear all,

Would like to seek help from the following VBA programing problem.

I have a form with an OLE object which is an excel with a chart inside.
The function i wrote is to delete one of the Shape on the worksheet of the
OLE object.

The codes are as follow:

Private Sub Command0_Click()

Set objchart = Me![oleChart_1].Object
objchart.Sheets("Chart").Shapes("CHT_BLK_L1").Delete

End Sub

When i run the code, error prompts: "Application-defined or object-defined
error"
However, such error would not appear if an excel application is opened and
running somewhere else. It can be resolved by create an excel application
object before running the two lines code. However, it is not stable.

Might anyone advise me how to run the code in a better way?

Thank you for your kind assistance in advance.
Regards
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top