View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Unable to Lock a Range

Dim oleObj as OleObject
Dim rng as Range
for each oleObj in ActiveWorkbook.Sheets( _
"Contract Master Order").OleObjects
if typeof oleObj.Object is MSForms.TextBox then
set rng = oleObj.TopLeftCell
rng.Value = oleObj.Object.Value
oleObj.Delete
end if
Next

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Many thanks.

Dimmed oleObj As OleObject.
Code then removed the textboxes and the entries.

I set the textboxes up as follows:
select a cell in the sheet
click ViewToolbars
select Control Toolbox
select Textbox
click on the same cell and drag to expand the range
right click the Control and choose Properties
enable Tab, Return and WrapText
(nb: couldn't see how to make text align to Top)
exit Design mode

This must be different to how you envisaged I had
created them?

Regards and Thanks.

"Tom Ogilvy" wrote in message
...
for each oleObj in ActiveWorkbook.Sheets( _
"Contract Master Order").OleObjects
if typeof oleObj.Object is MSForms.TextBox then
oleObj.Delete
end if
Next

Assumes the textboxes are linked to cells. Deleting the textbox

shouldn't
affect the value in the cell.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
Many thanks to you both.

You're both right. It was protected.
I'd set a breakpoint and I then used unprotect code in
the Immediate window before continuing on to step
through the Locked code.
Because it kept throwing the same error, I was looking
for some other problem.

I'd still be grateful for instruction regarding removing
the ActiveX textboxes (but preserving the text entries)
before I save the book, please.

Regards and thanks.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.716 / Virus Database: 472 - Release Date: 05/07/2004