Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Commandbar questions about .OnAction and msoFloating

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benjamino5 - 18 Aug 2006 19:10 GMT
I have two questions about Commandbars I haven't yet found answers to. Any
tips would be greatly appreciated!

1) I want several CommandBarButtons to call the same subprocedure, but with
different arguments. Yet it seems you can't put arguments in the .OnAction
property--you can only put the name of a sub in there. So how do you make a
button call a sub and also pass it an argument?

I'm guessing the Parameter property might be the answer, but I don't know
how to use it, so a code sample would really help me.

2) When creating a floating palette (commandbar with the property
"msoFloating"), I want the buttons on it to be arranged vertically, one on
top of the next, NOT horizontally. How do I do this? The .Width property of a
commandbar is apparently read-only, so I can't set it.
Helmut Weber - 18 Aug 2006 19:41 GMT
Hi Benjamin,

have a look at these,
just to get you started:

Sub Button1(): Doit 1: End Sub
Sub Button2(): Doit 2: End Sub
Sub Button3()
  Doit Len(ActiveDocument.Paragraphs(1).Range.Text)
End Sub

Sub Doit(lngA As Long)
Dim lngB As Long
For lngB = 1 To lngA
  MsgBox "Yes"
Next
End Sub

Sub positionCmdBar()
With ActiveDocument.CommandBars("Formatting")
  .Position = msoBarRight
End With
End Sub

' ---------------------------------
Also,
you may use only one button and check,
whether it was clicked together
with [alt] or [ctrl] or [shift],
or combinations of these.

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

Sub positionCmdBar()
With ActiveDocument.CommandBars("Formatting")
  .Position = msoBarRight
End With
End Sub

But, for positioning a commandbar
in autoopen or autonew,
things may be a bit different.
If that applies to you, ask again.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Benjamino5 - 18 Aug 2006 19:59 GMT
Helmut,

Thank you for your response!

The way you've done the buttons is actually how I was already doing it--I
just was hoping to simplify it. But that will certainly work.

More importantly, I still have a problem with the commandbar. It's not that
I want it to be docked to the right (msoBarRight), it's that I want it to be
floating AND for the buttons on the commandbar to be laid out vertically.

If you take a standard Word toolbar and drag it to the middle of the screen,
it floats in one long horizontal line. But you can then resize it so that the
commands are stacked. That's how I want my floating toolbars to look--for the
commands to be stacked on top of the other--but still be floating, not docked
on one side of the screen.

Thanks again for your help.
Helmut Weber - 18 Aug 2006 20:27 GMT
Hi Benjamin,

with the Word version I've got right here and now,
I can't move toolbars with the mouse at all,
whether floating or not.

For your version, maybe,
the height property might help, like:

With ActiveDocument.CommandBars("Formatting")
  .Top = 100
  .Left = 100
  .Height = 1000
'   .Width = 1000
End With

I'm at the end of my wisdom with this,
hopefully someone else will know better.

Regards.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Benjamino5 - 18 Aug 2006 21:36 GMT
Thanks for all your help. Unfortunately, those suggestions don't result in
what I was hoping for, but I'll just have to leave this question unresolved
for now and move on.
Cindy M. - 19 Aug 2006 15:27 GMT
Hi Helmut,

> with the Word version I've got right here and now,
> I can't move toolbars with the mouse at all,
> whether floating or not.

Check the Commandbar.Protection property and make sure it's
set to "no protection". You may have been playing with this
once and set protection to not allow moving.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
Helmut Weber - 19 Aug 2006 16:36 GMT
Yesssss!

Thank you, Cindy.

Signature

Helmut

Cindy M. - 19 Aug 2006 15:27 GMT
Hi =?Utf-8?B?QmVuamFtaW5vNQ==?=,

> 1) I want several CommandBarButtons to call the same subprocedure, but with
> different arguments. Yet it seems you can't put arguments in the .OnAction
[quoted text clipped - 4 lines]
> how to use it, so a code sample would really help me.
>  
You can use any property, but the Parameter or the Tag properties of the calling
button are the usual ones to use, yes. To get that information in the macro, use
the ActionControl:
   Application.CommandBars.ActionControl.Tag 'or Parameter, or Caption

> 2) When creating a floating palette (commandbar with the property
> "msoFloating"), I want the buttons on it to be arranged vertically, one on
> top of the next, NOT horizontally. How do I do this? The .Width property of a
> commandbar is apparently read-only, so I can't set it.

What I generally do is set the WIDTH of the CommandBar so that it's only just
wide enough for one control.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.