LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default OLEObjects.Add strange behaviour

I dont know if this the right place to submit what I suspect to be a bug
in the OLEObjects Add method. Please apologize if not.

When invoking the Add method on the OLEObjects collection of a worksheet
we can indicate the coordinates and size of the control. This method
seems not to work correctly when the zoom is set to a value lower than
100%. The position of the control is good except for it's Top value.
If the coordinates are set after the control's creation, the position is
correct.
Here is some example code :

Sub IsThisABug()
Dim aRange As range

Application.ActiveWindow.Zoom = 50

Set aRange = range("A1500")
aRange.Select
aRange.Show

' The control appears around cell A1416 instead of A1500
Application.ActiveSheet.OLEObjects.Add "Forms.Combobox.1" _
, , , , , , , _
aRange.Left, aRange.Top, aRange.Width, aRange.Height

Set aRange = Nothing
End Sub

Sub ThisOneWorks()
Dim aRange As range

Application.ActiveWindow.Zoom = 50

Set aRange = range("A1500")
aRange.Select
aRange.Show

' The control appears exactly on cell A1500
With Application.ActiveSheet.OLEObjects.Add("Forms.Comb obox.1")
.Left = aRange.Left
.Top = aRange.Top
.Width = aRange.Width
.Height = aRange.Height
End With

Set aRange = Nothing
End Sub

I'm not an Excel or VBA expert, so I hope not to have missed something.

PS: to contact me, replace the domain name of my address by prosim.net.
 
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
Strange if(***) behaviour? Excel 2003 - SPB Excel Discussion (Misc queries) 6 August 6th 06 05:34 PM
Automation behaviour - strange but very useful Robert Chapman[_3_] Excel Programming 2 April 11th 05 09:43 AM
Strange behaviour Edgar Thoemmes Excel Worksheet Functions 1 February 8th 05 03:20 PM
Strange behaviour in VBA Help Michael Singmin Excel Programming 4 June 4th 04 07:06 PM
strange behaviour Patrick Molloy Excel Programming 0 September 4th 03 07:51 AM


All times are GMT +1. The time now is 08:34 AM.

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

About Us

"It's about Microsoft Excel"