How To embed and automate Excel with Visual Basic?

C

Chris

I would like to seek help on how To embed and automate Excel with Visual
Basic.

Refer to
http://support.microsoft.com/kb/q242243/

I have extract a few lines of coding, with an excel embedded in the form
already.


Private Sub Command0_Click()

'Reference to the Microsoft Excel 9.0 Object Library.
Dim xlBook As Excel.Workbook
Set xlBook = Me![oleChart_1].Object
xlBook.Sheets(2).Select
xlBook.Sheets(2).Activate
xlBook.Sheets(2).Range("A1:C1").Select

End Sub

However, i fail to select the range, with run-time error '1004' Select
method of Range class failed


Might anyone help?
Thanks in adavnce!

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