problem with selection when calling macro externally from VB6

  • Thread starter Thread starter philipl
  • Start date Start date
P

philipl

hi I have the following code which runs fine when i call it from
within the macro of the spreadsheet. However when I canll it from
outside, ie from vb6. I get a type mismatched error when i try and
protect the cells.

Has any one ever seen this before, is there any way around this? Is
the obvious just to not use selection and manually set each cell
indivually?

here the code - thx alot.


ActiveSheet.Cells.Select
Selection.Locked = True <---gives me a type mismatch problem
here when i call from outside
ActiveSheet.Cells(1, 1).Select
 
Philip,

Have you created an Excel object, and referenced the Excel objects through
that application object.

For instance

Set xlApp = GetObject("Excel.Application")
Set xlWb = xlAPp.ActiveWorkbook
xlWb.ActiveSheet.Cells.Locked = True

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top