LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
jjk jjk is offline
external usenet poster
 
Posts: 42
Default Modeless userform OLEObject Add problem

Hi,

I have a form that among other things tries to add OLEObject controls
to the active sheet.

The issue is that the userform disappears if there is a transaction
where a control needs to be added on the worksheet. No exit event
handlers (Deactivate, Terminate, Error) are fired when this happens.
If there is no necessity to add an OLEObject then the form works fine.
I tested it by commenting the OLEObject.add call. It worked fine.
I also inserted several debug messages and all procedures execute till
completion. After which the modal form disappear.
If the form is modal then it works fine.

I am including a skeleton code below. Working code that simulates the
problem.

This thing is really stumping me.
Thanks,
Jayant


Worksheet Button click that brings up the form (UF)
--------------------------------------------------
Private Sub cmd_Click()
UF.startLine = 10
UF.Show (vbModeless)
End Sub

Userform UF code
----------------
Public startLine As Long

Private Sub UserForm_Activate()
ll.Caption = "Add at Line: " & startLine
End Sub

Private Sub cmdAdd_Click()

Dim sht As Worksheet
Dim o As OLEObject
Dim rng As Range

Set sht = ActiveSheet
Set rng = sht.Range("A" & startLine)


Set o =sht.OLEObjects.Add(classtype:="Forms.CommandButto n.1", _
Top:=rng.Top, Left:=rng.Left, Width:=rng.Width, _
Height:=rng.Height)
o.Name = "tempcmd_" & startLine

startLine = startLine + 1
ll.Caption = "Add at Line: " & startLine

End Sub

Private Sub UserForm_Deactivate()
MsgBox "I am not getting here"
End Sub

Private Sub UserForm_Error(ByVal Number As Integer, ByVal Description
As MSForms.ReturnString, ByVal SCode As Long, ByVal Source As String,
ByVal HelpFile As String, ByVal HelpContext As Long, ByVal
CancelDisplay As MSForms.ReturnBoolean)
MsgBox "I am not getting here"
End Sub

Private Sub UserForm_Terminate()
MsgBox "I am not getting here"
End Sub

 
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
Modeless userform hngo New Users to Excel 2 July 13th 05 09:23 AM
Modeless Userform problem Harald Staff Excel Programming 1 September 3rd 04 06:28 PM
Modeless Userform problem Robin Hammond[_2_] Excel Programming 0 September 2nd 04 02:29 PM
modeless userform jacob Excel Programming 1 May 4th 04 02:53 PM
Modeless userform jacob[_3_] Excel Programming 2 September 29th 03 08:02 PM


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

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"