Office 2007 Ribbon Customization (getPressed)

G

Greg

Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:
toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
P

Patrick Schmid [MVP]

Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
 
G

Greg

Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.

Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
P

Patrick Schmid [MVP]

They updated the articles? I missed that...
If you still have Beta 2, then the updates will make it so that it won't
work now. You should definitely upgrade to B2TR. It'll prob. give you an
error message with sharepoint though whenever you open 2003.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.

Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
G

Greg

Patrick,

Here is my XML customization text:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="CustomTab" label="My Tab">
<group id="SampleGroup" label="Sample Group">
<toggleButton id="ToggleButton1" size="large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />
<checkBox id="CheckBox1" label="A CheckBox"
screentip="This is a check box"
onAction="ThisDocument.MyCheckboxMacro" />
</group>
<group id="MyGroup" label="My Group" >
<button id="Button1" label="My Large Button"
size="large" onAction="ThisDocument.MyButtonMacro" />
<button id="Button2" label="My Normal Button"
size="normal" onAction="ThisDocument.MyOtherButtonMacro" />
</group >
</tab>
</tabs>
</ribbon>
</customUI>


Here is my VBA code:
Option Explicit
Sub MyOtherButtonMacro(ByVal control As IRibbonControl)
MsgBox "You clicked my normal button"
End Sub
Sub MyButtonMacro(ByVal control As IRibbonControl)
MsgBox "You clicked my large button"
End Sub
Sub MyCheckBoxMacro(ByVal control As IRibbonControl, bState As Boolean)
If bState Then
MsgBox "I'm checked."
Else
MsgBox "I'm not checked."
End If
End Sub
Sub MyToggleMacro(ByVal control As IRibbonControl, togState As Variant)
togState = True
MsgBox "The togglebutton is initially toggled on."
End Sub
Sub MyActionMacro(ByVal control As IRibbonControl, bToggle As Boolean)
If bToggle Then
MsgBox "I'm toggled on"
Else
MsgBox "I'm toggled off"
End If
End Sub

I have changed the code in MyToggleMacro such that I don't get the
error reported earlier and it appears to set the initial state of the
togglebutton to "on."

Is this the purpose of the getPressed attribute and how it is intended
to be used?

I also don't understand why "togState" can't be declared as a boolean
value. Apparently a toggle button can have 3 or more states when
intuitively it would seem to have just two (true or false). I tried
using togState as Boolean and I got a type mismatch error.

I know that you advised that I install B2TR, but in view of the
conflicts with Office2003 (which I used 99.9% of the time) I think I
will hold off until I decide to go full court with Office2007. That
day may never come ;-)


Thanks.


They updated the articles? I missed that...
If you still have Beta 2, then the updates will make it so that it won't
work now. You should definitely upgrade to B2TR. It'll prob. give you an
error message with sharepoint though whenever you open 2003.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.

Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
P

Patrick Schmid [MVP]

I have changed the code in MyToggleMacro such that I don't get the
error reported earlier and it appears to set the initial state of the
togglebutton to "on."
Get rid off all the "ThisDocument." Stuff in your callbacks. Everything
works once I remove that.
Is this the purpose of the getPressed attribute and how it is intended
to be used?
You are supposed to return true or false, depending on what you want it
to be.

I also don't understand why "togState" can't be declared as a boolean
value. Apparently a toggle button can have 3 or more states when
intuitively it would seem to have just two (true or false). I tried
using togState as Boolean and I got a type mismatch error.
It's a Boolean. The issue just is that the VBA function signature can't
handle a Boolean. If you write a COM add-in with C# e.g., the signature
is a Boolean.

I know that you advised that I install B2TR, but in view of the
conflicts with Office2003 (which I used 99.9% of the time) I think I
will hold off until I decide to go full court with Office2007. That
day may never come ;-)
Haha. February 1 it will come. That's when B2 expires ;)

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
Thanks.


They updated the articles? I missed that...
If you still have Beta 2, then the updates will make it so that it won't
work now. You should definitely upgrade to B2TR. It'll prob. give you an
error message with sharepoint though whenever you open 2003.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.


Patrick Schmid [MVP] wrote:
Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
G

Greg

Patrick,

Thanks. Everything worked with the ThisDocument but I removed it.
"ThisDocument" was included in the sample code from the article.

There was also code for a "editBox," "comboBox," and
"dialogBoxLauncher"

<editBox id="EditBox1" getText="ThisDocument.MyTextMacro"
label="My EditBox" onChange="ThisDocument.MyEditBoxMacro"/>
<comboBox id="Combo1" label="My ComboBox"
onChange="ThisDocument.MyComboBoxMacro">
<item id="Zip1" label="33455" />
<item id="Zip2" label="81611" />
<item id="Zip3" label="31561" />
</comboBox>
<dialogBoxLauncher>
<button id="Launcher1" screentip="My Launcher"
onAction="ThisDocument.MyLauncherMacro" />
</dialogBoxLauncher>

which I added. It appears that the dialogBoxLauncher is something new
to B2 and will not work. I added the following code using macronames
provided above. One sets the initial value of the editBox text.
Again, I would have thought myText As String would have worked, but I
get a type mismatch error. Seems a string works going one way but not
the other. That is odd ;-(

Sub MyTextMacro(ByVal control As IRibbonControl, myText As Variant)
myText = "Hello World"
End Sub
Sub MyEditboxMacro(ByVal cotnrol As IRibbonControl, txtEB As String)
MsgBox txtEB
End Sub
Sub MyComboBoxMacro(ByVal control As IRibbonControl, bEntry As String)
MsgBox bEntry
End Sub

It is really too bad that MS can let two versions run apparently
seemlessly in Beta but not in final production. I suppose I will have
to figure out how to make a virtual machine, by a another PC or forget
about using Word2007.

Thanks for your help.
I have changed the code in MyToggleMacro such that I don't get the
error reported earlier and it appears to set the initial state of the
togglebutton to "on."
Get rid off all the "ThisDocument." Stuff in your callbacks. Everything
works once I remove that.
Is this the purpose of the getPressed attribute and how it is intended
to be used?
You are supposed to return true or false, depending on what you want it
to be.

I also don't understand why "togState" can't be declared as a boolean
value. Apparently a toggle button can have 3 or more states when
intuitively it would seem to have just two (true or false). I tried
using togState as Boolean and I got a type mismatch error.
It's a Boolean. The issue just is that the VBA function signature can't
handle a Boolean. If you write a COM add-in with C# e.g., the signature
is a Boolean.

I know that you advised that I install B2TR, but in view of the
conflicts with Office2003 (which I used 99.9% of the time) I think I
will hold off until I decide to go full court with Office2007. That
day may never come ;-)
Haha. February 1 it will come. That's when B2 expires ;)

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
Thanks.


They updated the articles? I missed that...
If you still have Beta 2, then the updates will make it so that it won't
work now. You should definitely upgrade to B2TR. It'll prob. give you an
error message with sharepoint though whenever you open 2003.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.


Patrick Schmid [MVP] wrote:
Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
P

Patrick Schmid [MVP]

I can tell you that with RTM, Word 2003 and 2007 are playing a wonderful
game of Windows Installer. Whenever you switch between them, Windows
Installer runs for at least one minute. Excel & PPT don't do this, but
Access does the same annoying thing.
In B2, you have to use advanced instead of dialogBoxLauncher.

It can very well be that it works with ThisDocument for you, but I tried
it here with RTM and it didn't work.
You did look at this document:
http://msdn2.microsoft.com/en-us/ms406047.aspx
It lists all callbacks in VBA and specifies exactly what signatures you
need to use.

You really need to go to B2TR or RTM, if you want to go any further with
this...

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Patrick,

Thanks. Everything worked with the ThisDocument but I removed it.
"ThisDocument" was included in the sample code from the article.

There was also code for a "editBox," "comboBox," and
"dialogBoxLauncher"

<editBox id="EditBox1" getText="ThisDocument.MyTextMacro"
label="My EditBox" onChange="ThisDocument.MyEditBoxMacro"/>
<comboBox id="Combo1" label="My ComboBox"
onChange="ThisDocument.MyComboBoxMacro">
<item id="Zip1" label="33455" />
<item id="Zip2" label="81611" />
<item id="Zip3" label="31561" />
</comboBox>
<dialogBoxLauncher>
<button id="Launcher1" screentip="My Launcher"
onAction="ThisDocument.MyLauncherMacro" />
</dialogBoxLauncher>

which I added. It appears that the dialogBoxLauncher is something new
to B2 and will not work. I added the following code using macronames
provided above. One sets the initial value of the editBox text.
Again, I would have thought myText As String would have worked, but I
get a type mismatch error. Seems a string works going one way but not
the other. That is odd ;-(

Sub MyTextMacro(ByVal control As IRibbonControl, myText As Variant)
myText = "Hello World"
End Sub
Sub MyEditboxMacro(ByVal cotnrol As IRibbonControl, txtEB As String)
MsgBox txtEB
End Sub
Sub MyComboBoxMacro(ByVal control As IRibbonControl, bEntry As String)
MsgBox bEntry
End Sub

It is really too bad that MS can let two versions run apparently
seemlessly in Beta but not in final production. I suppose I will have
to figure out how to make a virtual machine, by a another PC or forget
about using Word2007.

Thanks for your help.
I have changed the code in MyToggleMacro such that I don't get the
error reported earlier and it appears to set the initial state of the
togglebutton to "on."
Get rid off all the "ThisDocument." Stuff in your callbacks. Everything
works once I remove that.
Is this the purpose of the getPressed attribute and how it is intended
to be used?
You are supposed to return true or false, depending on what you want it
to be.

I also don't understand why "togState" can't be declared as a boolean
value. Apparently a toggle button can have 3 or more states when
intuitively it would seem to have just two (true or false). I tried
using togState as Boolean and I got a type mismatch error.
It's a Boolean. The issue just is that the VBA function signature can't
handle a Boolean. If you write a COM add-in with C# e.g., the signature
is a Boolean.

I know that you advised that I install B2TR, but in view of the
conflicts with Office2003 (which I used 99.9% of the time) I think I
will hold off until I decide to go full court with Office2007. That
day may never come ;-)
Haha. February 1 it will come. That's when B2 expires ;)

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
Thanks.



Patrick Schmid [MVP] wrote:
They updated the articles? I missed that...
If you still have Beta 2, then the updates will make it so that it won't
work now. You should definitely upgrade to B2TR. It'll prob. give you an
error message with sharepoint though whenever you open 2003.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.


Patrick Schmid [MVP] wrote:
Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 
P

Patrick Schmid [MVP]

I know (I am running RTM off of MSDN already), but he is still running
Beta 2 and wants to stay at Beta 2 ;)
So for him, the Beta 2 expiration February 1 will force a decision.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
 
G

Greg

Patrick,

Thanks.

<You did look at this document:
http://msdn2.microsoft.com/en-us/ms406047.aspx
<It lists all callbacks in VBA and specifies exactly what signatures
you need to use.

I don't think I need to tell you that I am don't even consider myself a
novice in this field. I did read that article and just looked through
it again.

I don't follow "specificies exactly what signatures you need to use."
For example, if I look at the section on toggleButton there is a Table
12 that list "getPressed." It says nothing about returning true or
false or what declaration to use e.g., variant or boolean etc.
Obviously I am missing your point. Can you clarify?

The problems that you decribed here and in the Word Private newsgroup
with the Windows Installer are exactly why I will most likely stick to
Office2003. Should I decided to have a dual installation, do you know
if the RTM version that you are using will now turn into a pumkin at
some near term date?

Thanks.
I can tell you that with RTM, Word 2003 and 2007 are playing a wonderful
game of Windows Installer. Whenever you switch between them, Windows
Installer runs for at least one minute. Excel & PPT don't do this, but
Access does the same annoying thing.
In B2, you have to use advanced instead of dialogBoxLauncher.

It can very well be that it works with ThisDocument for you, but I tried
it here with RTM and it didn't work.
You did look at this document:
http://msdn2.microsoft.com/en-us/ms406047.aspx
It lists all callbacks in VBA and specifies exactly what signatures you
need to use.

You really need to go to B2TR or RTM, if you want to go any further with
this...

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Patrick,

Thanks. Everything worked with the ThisDocument but I removed it.
"ThisDocument" was included in the sample code from the article.

There was also code for a "editBox," "comboBox," and
"dialogBoxLauncher"

<editBox id="EditBox1" getText="ThisDocument.MyTextMacro"
label="My EditBox" onChange="ThisDocument.MyEditBoxMacro"/>
<comboBox id="Combo1" label="My ComboBox"
onChange="ThisDocument.MyComboBoxMacro">
<item id="Zip1" label="33455" />
<item id="Zip2" label="81611" />
<item id="Zip3" label="31561" />
</comboBox>
<dialogBoxLauncher>
<button id="Launcher1" screentip="My Launcher"
onAction="ThisDocument.MyLauncherMacro" />
</dialogBoxLauncher>

which I added. It appears that the dialogBoxLauncher is something new
to B2 and will not work. I added the following code using macronames
provided above. One sets the initial value of the editBox text.
Again, I would have thought myText As String would have worked, but I
get a type mismatch error. Seems a string works going one way but not
the other. That is odd ;-(

Sub MyTextMacro(ByVal control As IRibbonControl, myText As Variant)
myText = "Hello World"
End Sub
Sub MyEditboxMacro(ByVal cotnrol As IRibbonControl, txtEB As String)
MsgBox txtEB
End Sub
Sub MyComboBoxMacro(ByVal control As IRibbonControl, bEntry As String)
MsgBox bEntry
End Sub

It is really too bad that MS can let two versions run apparently
seemlessly in Beta but not in final production. I suppose I will have
to figure out how to make a virtual machine, by a another PC or forget
about using Word2007.

Thanks for your help.
I have changed the code in MyToggleMacro such that I don't get the
error reported earlier and it appears to set the initial state of the
togglebutton to "on."
Get rid off all the "ThisDocument." Stuff in your callbacks. Everything
works once I remove that.

Is this the purpose of the getPressed attribute and how it is intended
to be used?
You are supposed to return true or false, depending on what you want it
to be.


I also don't understand why "togState" can't be declared as a boolean
value. Apparently a toggle button can have 3 or more states when
intuitively it would seem to have just two (true or false). I tried
using togState as Boolean and I got a type mismatch error.
It's a Boolean. The issue just is that the VBA function signature can't
handle a Boolean. If you write a COM add-in with C# e.g., the signature
is a Boolean.



I know that you advised that I install B2TR, but in view of the
conflicts with Office2003 (which I used 99.9% of the time) I think I
will hold off until I decide to go full court with Office2007. That
day may never come ;-)
Haha. February 1 it will come. That's when B2 expires ;)

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed



Thanks.



Patrick Schmid [MVP] wrote:
They updated the articles? I missed that...
If you still have Beta 2, then the updates will make it so that it won't
work now. You should definitely upgrade to B2TR. It'll prob. give you an
error message with sharepoint though whenever you open 2003.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Patrick,

Yes I will when I get home later this evening. I became discouraged
with Word2007 not long after my budding attempts to customize the
ribbon back in May/June when you proved so helpful.

I still have the Beta2 application installed and never installed the
B2TR. Do you know if I install the B2TR if I will still be able to run
both Word2003 and Word2007 without conflict?

BTW, those articles where updated in October and November.

Thanks.


Patrick Schmid [MVP] wrote:
Hi Greg,

Can you post your full RibbonX?
The series you read is for B2 and quite a few things have changed since
then.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


Hello,

I am dabbling with customization of the Office 2007 Ribbon. I have
read the series of articles at MSDN on Customizing the Office (2007)
Ribbon UI for Developers. I have some questions about the purpose,
use, and coding of the the toggleButton attribute "getPressed."

For practice, I used the example customization XML provided in the part
1 of the article. It adds a custom tab with a toggle button the XML
for the togglebutton is:

toggleButton id="ToggleButton1" Size="Large"
label="Large Toggle Button"
getPressed="ThisDocument.MyToggleMacro"
onAction="ThisDocument.MyActionMacro" />

In part 2 of the article it states that the getPressed attribute is of
the callback type and enables you to specify whether the toggle button
control is pressed.

I have the following VBA code in myPractice.dotm file

Sub MyActionMacro (ByRef control as IRibbonControl)
MsgBox "TestMyAction")
End Sub

Sub MyToggleMacro (ByRef control as IRibbonControl)
MsgBox "TestMyToggle"
End Sub

Now when I open myPractice.dotm the custom tab appears. When I click
on the tab, the VBA editor throws an error indicating I have the wrong
number of arguments. I click ok, and my custom ribbon then appears
with the toggle button. If I "press" it, then I get the message box
"TestMyAction"

I never get the message TestMyToggle, and if I subsequently select
another tab and then the custom tab again, I don't get a repeat of the
error. (Note, if I close and reopen the file I do get the error the
first time I click the custom tab).

It appears, that pressing the custom tab the first time fires the
MyToggleMacro and that is supposed to set the initial condition of the
toggle.

Is that assumption correct?

How do I code the MyToggleMacro such that it contains the right number
of arguments and then sets the toggle to either of its two states?

Thanks.
 

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