Dear Mr Excel,
I have registered today and this is my first post so please forgive any mistakes in how I present my question.
After searching a range of forums already I can't find a reference to this particular problem anywhere.
My issue is with a CommandBar Popup which appears when you right-click in a textbox on my userform giving two command buttons: copy and paste.
When the user right-clicks the textbox, the popup is not appearing correctly as shown in the image at the link below.
http://postimage.org/image/2ewlgahqc/
If the user notices the faint outline of the popup and hovers over the buttons then they appear as shown in the second image/link.
http://postimage.org/image/2eynvh3yc/
Once the user has clicked one of the buttons then any further right-clicks display the popup correctly.
The only property which seems likely to have any impact on the visibility of the popup is the .visible but even with this set to True the popup misbehaves first time.
I have altered my code a number of times and although the function of the popup is the same, every alteration results in the invisible popup.
Public Sub TBEnqdetails_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = vbKeyRButton Then
Set ctl = UserForm2.Controls("TBEnqDetails")
CreateCmdBar
CommandBars("tbCmdBar").ShowPopup
End If
End Sub
Public Sub CreateCmdBar()
CmdBarDel ' to prevent duplications
With CommandBars.Add("tbCmdBar", Position:=msoBarPopup)
.Controls.Add(Type:=msoControlButton, ID:=19).OnAction = "CopySub"
.Controls.Add(Type:=msoControlButton, ID:=22).OnAction = "PasteSub"
End With
End Sub
Public Sub CmdBarDel()
On Error Resume Next
CommandBars("tbCmdBar").Delete
End Sub
Public Sub copysub()
Set MyData = New DataObject
If ctl.SelText <> "" Then
MyData.SetText ctl.SelText
Else
MyData.SetText ctl.Text
End If
MyData.PutInClipboard
ctl.Text = ctl.Text
CmdBarDel
End Sub
Public Sub pastesub()
Set MyData = New DataObject
MyData.GetFromClipboard
If ctl.SelText = "" Then
ctl.Text = ctl.Text & MyData.GetText
Else
ctl.SelText = MyData.GetText
End If
CmdBarDel
End Sub
Thanks in advance for any help.
I have registered today and this is my first post so please forgive any mistakes in how I present my question.
After searching a range of forums already I can't find a reference to this particular problem anywhere.
My issue is with a CommandBar Popup which appears when you right-click in a textbox on my userform giving two command buttons: copy and paste.
When the user right-clicks the textbox, the popup is not appearing correctly as shown in the image at the link below.
http://postimage.org/image/2ewlgahqc/
If the user notices the faint outline of the popup and hovers over the buttons then they appear as shown in the second image/link.
http://postimage.org/image/2eynvh3yc/
Once the user has clicked one of the buttons then any further right-clicks display the popup correctly.
The only property which seems likely to have any impact on the visibility of the popup is the .visible but even with this set to True the popup misbehaves first time.
I have altered my code a number of times and although the function of the popup is the same, every alteration results in the invisible popup.
Public Sub TBEnqdetails_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = vbKeyRButton Then
Set ctl = UserForm2.Controls("TBEnqDetails")
CreateCmdBar
CommandBars("tbCmdBar").ShowPopup
End If
End Sub
Public Sub CreateCmdBar()
CmdBarDel ' to prevent duplications
With CommandBars.Add("tbCmdBar", Position:=msoBarPopup)
.Controls.Add(Type:=msoControlButton, ID:=19).OnAction = "CopySub"
.Controls.Add(Type:=msoControlButton, ID:=22).OnAction = "PasteSub"
End With
End Sub
Public Sub CmdBarDel()
On Error Resume Next
CommandBars("tbCmdBar").Delete
End Sub
Public Sub copysub()
Set MyData = New DataObject
If ctl.SelText <> "" Then
MyData.SetText ctl.SelText
Else
MyData.SetText ctl.Text
End If
MyData.PutInClipboard
ctl.Text = ctl.Text
CmdBarDel
End Sub
Public Sub pastesub()
Set MyData = New DataObject
MyData.GetFromClipboard
If ctl.SelText = "" Then
ctl.Text = ctl.Text & MyData.GetText
Else
ctl.SelText = MyData.GetText
End If
CmdBarDel
End Sub
Thanks in advance for any help.