Macro Problem in Word 2007

J

Jerry

I just got Office 2007 Beta 2. I have a Word template that I want to use. As
expected, the custom toolbars from this template appear inside of the Add-Ins
ribbon. All of the macros work fine except for one. This macro allows the
user to customize on the spot by adding a button to one of these custom
toolbars. (There is another macro that allows the user to remove the same
button.) In earlier versions of Word this macro will name the button with the
exact name of the style that the user enters. This does not happen in Word
2007; eventhough the added buttons function correctly, they are always named
"Apply Style Name."

Can this be fixed? Thanks, Jerry

Here are the two macros:

Sub AddButton()
'
'added by GMP
'
Dim eName As String

eName = InputBox("Enter the exact name of the element you would like to
add as a button.", "Adding Element Button", "text")

Set newbutton = CommandBars("Basic
Elements").Controls.Add(Type:=msoControlButton, ID:=2321, Parameter:=eName)

newbutton.Caption = eName

nReply = InputBox("Would you like to add another element button? (y or
n)?", "Add Another Button?", "n")

'Add another button loop

Do Until nReply = "n"

eName = InputBox("Enter the exact name of the element you would like to
add as a button.", "Adding Element Button", "text")

Set newbutton = CommandBars("Basic
Elements").Controls.Add(Type:=msoControlButton, ID:=2321, Parameter:=eName)

newbutton.Caption = eName

nReply = InputBox("Would you like to add another element button? (y or
n)?", "Add Another Button?", "n")

Loop

End Sub
Sub RemoveButton()
'
'added by GMP
'
Dim eName As String

eName = InputBox("Enter the exact name of the element button you would
like to remove.", "Removing Element Button", "text")

CommandBars("Basic Elements").Controls(eName).Delete

nReply = InputBox("Would you like to remove another element button?" &
vbCr & "(y or n)?", "Remove Another Button?", "n")

'Remove another button loop

Do Until nReply = "n"

eName = InputBox("Enter the exact name of the element button you would
like to remove.", "Removing Element Button", "text")

CommandBars("Basic Elements").Controls(eName).Delete

nReply = InputBox("Would you like to remove another element button? (y or
n)?", "Remove Another Button?", "n")

Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top