Error in Automating Excel

  • Thread starter Srinivas Chundi
  • Start date
S

Srinivas Chundi

I have a module in my excel spreadsheet that has following code in it.

Sub GetPicture
Dim xlsheet as Excel.Worksheet
Set xlsheet = New Excel.Worksheet
....
....
Set xlsheet = nothing

End Sub

The objective is to create a new temporary worksheet within the Sub and
destroy it at the end of sub so that the other worksheets do not have to be
disutrbed. When I execute the first statement I get the following error.

Error num 430 Class does not support automation or does not support expected
interface.
I tried the statement Set xlsheet = CreateObject("Excel.Worksheet"), but
that fails too with the message "Acitvex object cannot create object"
Please help
-- M
 
B

Bill James

Try:

Sub GetPicture()
Dim x As Excel.Worksheet
Dim xlsheet As New Excel.Worksheet '<-- change here

'...

Set xlsheet = Nothing

End Sub
 

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