Hi,

I have a toolbar with a textbox - im trying to create a macro that will copy
the selected text and auto paste to the textbox in the toolbar.

This is what I thought would work but isint.....

Any help would be appreciated.

Sub Ldtaskbr()
'To paste selected text in 'Task' Toolbar

Dim sendList As CommandBarComboBox ' list of users (Textbox) (2)'

Set sendBar = Application.CommandBars("Task")
Set sendList2 = sendBar.Controls.Add(Type:=msoControlEdit, Before:=1)

Selection.Copy

With sendList2
.Text = Slection.Paste
End With

End Sub

Re: Paste to Toolbar Textbox by Helmut

Helmut
Tue Sep 18 15:31:02 CDT 2007

Hi Benz,

it must have been more than an hour
to find out whats wrong.

You have to define the control you add as msoControlComboBox.

No:
Controls.Add(Type:=msoControlEdit, Before:=1)
Yes:
Controls.Add(Type:=msoControlComboBox, Before:=1)

Otherwise you can set its text, but the additem-method fails.
Though setting the text of a combobox works,
it is entirely useless, as there would be
no different items to choose from.

' -------------------------------------------
Sub Ldtaskbr()
Dim sendbar As CommandBar
Dim sendbox As CommandBarComboBox
Set sendbar = Application.CommandBars("Custom01")
Set sendbox = sendbar.Controls.Add(Type:=msoControlComboBox, _
Before:=1)
End Sub

' -------------------------------------------

Sub test1()
Dim sendbar As CommandBar
Dim sendbox As CommandBarComboBox
Set sendbar = Application.CommandBars("Custom01")
Set sendbox = sendbar.Controls(1)
With sendbox
.AddItem Selection.Text
End With
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



Re: Paste to Toolbar Textbox by Benz

Benz
Tue Sep 18 15:58:01 CDT 2007

Thank you! I apprecaite the help. It's a textbox so there won't be any drop
down items. But im still not able to paste the selection to the textbox ,
what can I put in the place of 'add' to it has the right target?

Controls.Add(Type:=msoControlComboBox, Before:=1)


Thank you,

Ben Z.

"Helmut Weber" wrote:

> Hi Benz,
>
> it must have been more than an hour
> to find out whats wrong.
>
> You have to define the control you add as msoControlComboBox.
>
> No:
> Controls.Add(Type:=msoControlEdit, Before:=1)
> Yes:
> Controls.Add(Type:=msoControlComboBox, Before:=1)
>
> Otherwise you can set its text, but the additem-method fails.
> Though setting the text of a combobox works,
> it is entirely useless, as there would be
> no different items to choose from.
>
> ' -------------------------------------------
> Sub Ldtaskbr()
> Dim sendbar As CommandBar
> Dim sendbox As CommandBarComboBox
> Set sendbar = Application.CommandBars("Custom01")
> Set sendbox = sendbar.Controls.Add(Type:=msoControlComboBox, _
> Before:=1)
> End Sub
>
> ' -------------------------------------------
>
> Sub test1()
> Dim sendbar As CommandBar
> Dim sendbox As CommandBarComboBox
> Set sendbar = Application.CommandBars("Custom01")
> Set sendbox = sendbar.Controls(1)
> With sendbox
> .AddItem Selection.Text
> End With
> End Sub
>
> HTH
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>
>
>

Re: Paste to Toolbar Textbox by Helmut

Helmut
Tue Sep 18 16:16:00 CDT 2007

Hi Benz,

if it has to be, wondering why,

Sub Ldtaskbr()
Dim sendbar As CommandBar
Dim sendbox As CommandBarControl
Set sendbar = Application.CommandBars("Custom01")
Set sendbox = sendbar.Controls.Add(Type:=msoControlEdit, _
Before:=1)
End Sub

' -----------------------------------------------
Sub test1()

Dim sendbar As CommandBar
Dim sendbox As CommandBarControl
Set sendbar = Application.CommandBars("Custom01")
Set sendbox = sendbar.Controls(1)
With sendbox
.Text = Selection.Text
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"




Re: Paste to Toolbar Textbox by Benz

Benz
Tue Sep 18 16:36:02 CDT 2007

That works great , Thank you!

"Helmut Weber" wrote:

> Hi Benz,
>
> if it has to be, wondering why,
>
> Sub Ldtaskbr()
> Dim sendbar As CommandBar
> Dim sendbox As CommandBarControl
> Set sendbar = Application.CommandBars("Custom01")
> Set sendbox = sendbar.Controls.Add(Type:=msoControlEdit, _
> Before:=1)
> End Sub
>
> ' -----------------------------------------------
> Sub test1()
>
> Dim sendbar As CommandBar
> Dim sendbox As CommandBarControl
> Set sendbar = Application.CommandBars("Custom01")
> Set sendbox = sendbar.Controls(1)
> With sendbox
> .Text = Selection.Text
> End With
> End Sub
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>
>
>
>