Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default excel 2007 problem deleting an onsheet scrollbar

I wrote the following routine to delete an activeX scrollbar on a
worksheet. When first creating the scrollbar I give the .Name
property a value of my own choosing. My routine tries to use this
property to delete it.

Function DeleteScrollbar(s$) As Boolean
On Error Resume Next
ActiveSheet.OLEObjects(s).Delete
End Function

The above routine worked fine when I first tested it, but later it
would no longer work because of a run time error trying to access the
scrollbar object. Changing OleObjects to Scrollbars or to
DrawingObjects did not help.

I eventually got it to work as follows:

Function DeleteScrollbar(s$) As Boolean
Dim i
On Error Resume Next
With ActiveSheet.OLEObjects
For i = 1 To .Count
If .Item(i).Name = s Then
.Item(i).Delete
Exit For
End If
Next
End With
End Function

What I'm finding is that Excel 2007 acts unpredictably when using
a .Name property to work with on-sheet objects. For example, a For
Each loop would not work in the second routine above. Are there any
special tricks to using .Name properties in Excel 2007?

Thanks,

Brian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 461
Default excel 2007 problem deleting an onsheet scrollbar

Changing OleObjects to Scrollbars or to
DrawingObjects did not help.


Does Shapes(s) work?

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



Brian Murphy wrote:
I wrote the following routine to delete an activeX scrollbar on a
worksheet. When first creating the scrollbar I give the .Name
property a value of my own choosing. My routine tries to use this
property to delete it.

Function DeleteScrollbar(s$) As Boolean
On Error Resume Next
ActiveSheet.OLEObjects(s).Delete
End Function

The above routine worked fine when I first tested it, but later it
would no longer work because of a run time error trying to access the
scrollbar object. Changing OleObjects to Scrollbars or to
DrawingObjects did not help.

I eventually got it to work as follows:

Function DeleteScrollbar(s$) As Boolean
Dim i
On Error Resume Next
With ActiveSheet.OLEObjects
For i = 1 To .Count
If .Item(i).Name = s Then
.Item(i).Delete
Exit For
End If
Next
End With
End Function

What I'm finding is that Excel 2007 acts unpredictably when using
a .Name property to work with on-sheet objects. For example, a For
Each loop would not work in the second routine above. Are there any
special tricks to using .Name properties in Excel 2007?

Thanks,

Brian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default excel 2007 problem deleting an onsheet scrollbar

Yes, it does work! In an instance when OleObjects definitely does not
work, Shapes does work.

Thanks for the tip. I like it a lot better than what I had cobbled
together.

Cheers,

Brian


On Oct 14, 9:45 am, Jon Peltier wrote:
Changing OleObjects to Scrollbars or to
DrawingObjects did not help.


Does Shapes(s) work?

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.http://peltiertech.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 recalculating custom function when scrollbar is moved? ker_01 Excel Programming 1 July 14th 09 10:04 AM
Excel 2007 SP1 - How to correct scrollbar extent? Ron West Excel Discussion (Misc queries) 1 January 2nd 09 03:31 PM
Colour Cells onSheet Zone Excel Programming 1 December 20th 06 08:58 PM
ScrollBar Sheet problem [email protected] Excel Programming 4 May 28th 06 05:09 PM
Excel VBA - Userform Texbox/Scrollbar problem thesteelmaker[_5_] Excel Programming 2 March 6th 04 09:09 PM


All times are GMT +1. The time now is 11:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"