Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
DerbyDad03 DerbyDad03 is offline
external usenet poster
 
Posts: 48
Default Setting FaceID on Custom Button

I would like to change, via VBA, either the FaceID and/or the name on
a custom button that I have assigned to a macro.

Specifically, I want to be able click a specific button, have the code
run, and have the name and/or FaceID of *that* button change. It is
essentially a toggle button for an option and I want the FaceID or
name to tell me the current setting of that option.

The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.

Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Setting FaceID on Custom Button

Have a look at the VBA help on the ActionControl property. You can use the
property to change the Caption (name) or the FaceID of the control when it is
clicked.

Example:
You want your button to switch between the captions €śMyControl On€ť and
€śMyControl Off€ť.
You can obtain this by inserting e.g. the following code in the procedure
that that runs when you click the button:

With CommandBars.ActionControl
If .Caption = "MyControl On" Then
.Caption = "MyControl Off"
Else
.Caption = "MyControl On"
End If
End With

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:

I would like to change, via VBA, either the FaceID and/or the name on
a custom button that I have assigned to a macro.

Specifically, I want to be able click a specific button, have the code
run, and have the name and/or FaceID of *that* button change. It is
essentially a toggle button for an option and I want the FaceID or
name to tell me the current setting of that option.

The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.

Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
DerbyDad03 DerbyDad03 is offline
external usenet poster
 
Posts: 48
Default Setting FaceID on Custom Button

Thank you for that, it works fine. Now I need to expand the question
a bit.

I would still like to know how to determine the control number (?) for
a specific button. I have a Close event macro that sets the option to
the default that I would prefer, but that could result in the text for
my custom button being opposite of the actual option setting.

Specifically, I'm toggling the "Insert/paste pictures as" between In
Line and In Front. My Close event sets the option to In Front, but
that won't change the button text from "In Line Set" to "In Front Set"
so it matches the option the next time I open Word.

Here's the code I'm using:

Private Sub Document_Close()
'Set Paste Picture option to In Front upon Close
Options.PictureWrapType = wdWrapMergeFront
End Sub

Sub ImagePaste()
'Toggle Paste Picture option and
'Display current setting on button
With CommandBars.ActionControl
If .Caption = "In Line Set" Then
Options.PictureWrapType = wdWrapMergeFront
.Caption = "In Front Set"
Else
Options.PictureWrapType = wdWrapMergeInline
.Caption = "In Line Set"
End If
End With
End Sub

BTW...if this sounds silly to most of you, it's as much as exercise in
learning VBA for Word as well as automating an option change that I
use quite often. I can already think of other places where I can use
the ActionControl property, so I'm glad you pointed it out. I'm fairly
proficient with VBA for Excel and now I'm trying to expand my
horizons.

Thanks again!

On 13 Mar, 17:28, Lene Fredborg
wrote:
Have a look at the VBA help on the ActionControl property. You can use the
property to change the Caption (name) or theFaceIDof the control when it is
clicked.

Example:
You want your button to switch between the captions "MyControl On" and
"MyControl Off".
You can obtain this by inserting e.g. the following code in the procedure
that that runs when you click the button:

With CommandBars.ActionControl
If .Caption = "MyControl On" Then
.Caption = "MyControl Off"
Else
.Caption = "MyControl On"
End If
End With

--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word



"DerbyDad03" wrote:
I would like to change, via VBA, either theFaceIDand/or the name on
a custom button that I have assigned to a macro.


Specifically, I want to be able click a specific button, have the code
run, and have the name and/orFaceIDof *that* button change. It is
essentially a toggle button for an option and I want theFaceIDor
name to tell me the current setting of that option.


The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.


Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Setting FaceID on Custom Button

You can, for example, apply a Tag to your control. You can then use that tag
in combination with the FindControl method in order to identify the control.

Example:
You apply the tag €śMyTag€ť to your control (you can set the Tag property in
the same way as you set the caption). If you leave the tag of the control
unchanged and make sure that you use something unique as the tag string, you
can always find the control using the FindControl method (see the VBA help €“
you can use more parameters).

Dim oControl As CommandBarControl
Set oControl = CommandBars.FindControl(Tag:="MyTag")

You can now manipulate oControl as needed. For example, you can change the
Caption:
oControl.Caption = "Another Caption"

If I read your description correctly, it should be sufficient to add the
following line of code to your Close event procedure (provided you first
apply the Tag €śMyTag€ť to your control):

CommandBars.FindControl(Tag:="MyTag").Caption = "In Front Set"

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:

Thank you for that, it works fine. Now I need to expand the question
a bit.

I would still like to know how to determine the control number (?) for
a specific button. I have a Close event macro that sets the option to
the default that I would prefer, but that could result in the text for
my custom button being opposite of the actual option setting.

Specifically, I'm toggling the "Insert/paste pictures as" between In
Line and In Front. My Close event sets the option to In Front, but
that won't change the button text from "In Line Set" to "In Front Set"
so it matches the option the next time I open Word.

Here's the code I'm using:

Private Sub Document_Close()
'Set Paste Picture option to In Front upon Close
Options.PictureWrapType = wdWrapMergeFront
End Sub

Sub ImagePaste()
'Toggle Paste Picture option and
'Display current setting on button
With CommandBars.ActionControl
If .Caption = "In Line Set" Then
Options.PictureWrapType = wdWrapMergeFront
.Caption = "In Front Set"
Else
Options.PictureWrapType = wdWrapMergeInline
.Caption = "In Line Set"
End If
End With
End Sub

BTW...if this sounds silly to most of you, it's as much as exercise in
learning VBA for Word as well as automating an option change that I
use quite often. I can already think of other places where I can use
the ActionControl property, so I'm glad you pointed it out. I'm fairly
proficient with VBA for Excel and now I'm trying to expand my
horizons.

Thanks again!

On 13 Mar, 17:28, Lene Fredborg
wrote:
Have a look at the VBA help on the ActionControl property. You can use the
property to change the Caption (name) or theFaceIDof the control when it is
clicked.

Example:
You want your button to switch between the captions "MyControl On" and
"MyControl Off".
You can obtain this by inserting e.g. the following code in the procedure
that that runs when you click the button:

With CommandBars.ActionControl
If .Caption = "MyControl On" Then
.Caption = "MyControl Off"
Else
.Caption = "MyControl On"
End If
End With

--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word



"DerbyDad03" wrote:
I would like to change, via VBA, either theFaceIDand/or the name on
a custom button that I have assigned to a macro.


Specifically, I want to be able click a specific button, have the code
run, and have the name and/orFaceIDof *that* button change. It is
essentially a toggle button for an option and I want theFaceIDor
name to tell me the current setting of that option.


The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.


Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
DerbyDad03 DerbyDad03 is offline
external usenet poster
 
Posts: 48
Default Setting FaceID on Custom Button

Done...and working. Thanks!

Now, the last question would relate to efficiency.

I added the tag as part of my ActionControl routine, ran it once and
then commented it out, but left it in as a reminder. I didn't see any
other way to add a tag to an existing control, since I don't know how
to find the control via VBA unless it has a tag. g

Is that the best way to do it or is there a dropdown someplace that I
don't know about?

On 14 Mar, 11:46, Lene Fredborg
wrote:
You can, for example, apply a Tag to your control. You can then use that tag
in combination with the FindControl method in order to identify the control.

Example:
You apply the tag "MyTag" to your control (you can set the Tag property in
the same way as you set the caption). If you leave the tag of the control
unchanged and make sure that you use something unique as the tag string, you
can always find the control using the FindControl method (see the VBA help -
you can use more parameters).

Dim oControl As CommandBarControl
Set oControl = CommandBars.FindControl(Tag:="MyTag")

You can now manipulate oControl as needed. For example, you can change the
Caption:
oControl.Caption = "Another Caption"

If I read your description correctly, it should be sufficient to add the
following line of code to your Close event procedure (provided you first
apply the Tag "MyTag" to your control):

CommandBars.FindControl(Tag:="MyTag").Caption = "In Front Set"

--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word



"DerbyDad03" wrote:
Thank you for that, it works fine. Now I need to expand the question
a bit.


I would still like to know how to determine the control number (?) for
a specific button. I have a Close event macro that sets the option to
the default that I would prefer, but that could result in the text for
my custom button being opposite of the actual option setting.


Specifically, I'm toggling the "Insert/paste pictures as" between In
Line and In Front. My Close event sets the option to In Front, but
that won't change the button text from "In Line Set" to "In Front Set"
so it matches the option the next time I open Word.


Here's the code I'm using:


Private Sub Document_Close()
'Set Paste Picture option to In Front upon Close
Options.PictureWrapType = wdWrapMergeFront
End Sub


Sub ImagePaste()
'Toggle Paste Picture option and
'Display current setting on button
With CommandBars.ActionControl
If .Caption = "In Line Set" Then
Options.PictureWrapType = wdWrapMergeFront
.Caption = "In Front Set"
Else
Options.PictureWrapType = wdWrapMergeInline
.Caption = "In Line Set"
End If
End With
End Sub


BTW...if this sounds silly to most of you, it's as much as exercise in
learning VBA for Word as well as automating an option change that I
use quite often. I can already think of other places where I can use
the ActionControl property, so I'm glad you pointed it out. I'm fairly
proficient with VBA for Excel and now I'm trying to expand my
horizons.


Thanks again!


On 13 Mar, 17:28, Lene Fredborg
wrote:
Have a look at the VBA help on the ActionControl property. You can use the
property to change the Caption (name) or theFaceIDof the control when it is
clicked.


Example:
You want your button to switch between the captions "MyControl On" and
"MyControl Off".
You can obtain this by inserting e.g. the following code in the procedure
that that runs when you click the button:


With CommandBars.ActionControl
If .Caption = "MyControl On" Then
.Caption = "MyControl Off"
Else
.Caption = "MyControl On"
End If
End With


--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:
I would like to change, via VBA, either theFaceIDand/or the name on
a custom button that I have assigned to a macro.


Specifically, I want to be able click a specific button, have the code
run, and have the name and/orFaceIDof *that* button change. It is
essentially a toggle button for an option and I want theFaceIDor
name to tell me the current setting of that option.


The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.


Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Setting FaceID on Custom Button

As far as I have experienced, you can only add a tag via VBA. So the method
you used i OK.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:

Done...and working. Thanks!

Now, the last question would relate to efficiency.

I added the tag as part of my ActionControl routine, ran it once and
then commented it out, but left it in as a reminder. I didn't see any
other way to add a tag to an existing control, since I don't know how
to find the control via VBA unless it has a tag. g

Is that the best way to do it or is there a dropdown someplace that I
don't know about?

On 14 Mar, 11:46, Lene Fredborg
wrote:
You can, for example, apply a Tag to your control. You can then use that tag
in combination with the FindControl method in order to identify the control.

Example:
You apply the tag "MyTag" to your control (you can set the Tag property in
the same way as you set the caption). If you leave the tag of the control
unchanged and make sure that you use something unique as the tag string, you
can always find the control using the FindControl method (see the VBA help -
you can use more parameters).

Dim oControl As CommandBarControl
Set oControl = CommandBars.FindControl(Tag:="MyTag")

You can now manipulate oControl as needed. For example, you can change the
Caption:
oControl.Caption = "Another Caption"

If I read your description correctly, it should be sufficient to add the
following line of code to your Close event procedure (provided you first
apply the Tag "MyTag" to your control):

CommandBars.FindControl(Tag:="MyTag").Caption = "In Front Set"

--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word



"DerbyDad03" wrote:
Thank you for that, it works fine. Now I need to expand the question
a bit.


I would still like to know how to determine the control number (?) for
a specific button. I have a Close event macro that sets the option to
the default that I would prefer, but that could result in the text for
my custom button being opposite of the actual option setting.


Specifically, I'm toggling the "Insert/paste pictures as" between In
Line and In Front. My Close event sets the option to In Front, but
that won't change the button text from "In Line Set" to "In Front Set"
so it matches the option the next time I open Word.


Here's the code I'm using:


Private Sub Document_Close()
'Set Paste Picture option to In Front upon Close
Options.PictureWrapType = wdWrapMergeFront
End Sub


Sub ImagePaste()
'Toggle Paste Picture option and
'Display current setting on button
With CommandBars.ActionControl
If .Caption = "In Line Set" Then
Options.PictureWrapType = wdWrapMergeFront
.Caption = "In Front Set"
Else
Options.PictureWrapType = wdWrapMergeInline
.Caption = "In Line Set"
End If
End With
End Sub


BTW...if this sounds silly to most of you, it's as much as exercise in
learning VBA for Word as well as automating an option change that I
use quite often. I can already think of other places where I can use
the ActionControl property, so I'm glad you pointed it out. I'm fairly
proficient with VBA for Excel and now I'm trying to expand my
horizons.


Thanks again!


On 13 Mar, 17:28, Lene Fredborg
wrote:
Have a look at the VBA help on the ActionControl property. You can use the
property to change the Caption (name) or theFaceIDof the control when it is
clicked.


Example:
You want your button to switch between the captions "MyControl On" and
"MyControl Off".
You can obtain this by inserting e.g. the following code in the procedure
that that runs when you click the button:


With CommandBars.ActionControl
If .Caption = "MyControl On" Then
.Caption = "MyControl Off"
Else
.Caption = "MyControl On"
End If
End With


--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:
I would like to change, via VBA, either theFaceIDand/or the name on
a custom button that I have assigned to a macro.


Specifically, I want to be able click a specific button, have the code
run, and have the name and/orFaceIDof *that* button change. It is
essentially a toggle button for an option and I want theFaceIDor
name to tell me the current setting of that option.


The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.


Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
DerbyDad03 DerbyDad03 is offline
external usenet poster
 
Posts: 48
Default Setting FaceID on Custom Button

On Mar 14, 7:35*pm, Lene Fredborg
wrote:
As far as I have experienced, you can only add a tag via VBA. So the method
you used i OK.

--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word



"DerbyDad03" wrote:
Done...and working. Thanks!


Now, the last question would relate to efficiency.


I added the tag as part of my ActionControl routine, ran it once and
then commented it out, but left it in as a reminder. I didn't see any
other way to add a tag to an existing control, since I don't know how
to find the control via VBA unless it has a tag. g


Is that the best way to do it or is there a dropdown someplace that I
don't know about?


On 14 Mar, 11:46, Lene Fredborg
wrote:
You can, for example, apply a Tag to your control. You can then use that tag
in combination with the FindControl method in order to identify the control.


Example:
You apply the tag "MyTag" to your control (you can set the Tag property in
the same way as you set the caption). If you leave the tag of the control
unchanged and make sure that you use something unique as the tag string, you
can always find the control using the FindControl method (see the VBA help -
you can use more parameters).


* * Dim oControl As CommandBarControl
* * Set oControl = CommandBars.FindControl(Tag:="MyTag")


You can now manipulate oControl as needed. For example, you can change the
Caption:
* * oControl.Caption = "Another Caption"


If I read your description correctly, it should be sufficient to add the
following line of code to your Close event procedure (provided you first
apply the Tag "MyTag" to your control):


CommandBars.FindControl(Tag:="MyTag").Caption = "In Front Set"


--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:
Thank you for that, it works fine. *Now I need to expand the question
a bit.


I would still like to know how to determine the control number (?) for
a specific button. *I have a Close event macro that sets the option to
the default that I would prefer, but that could result in the text for
my custom button being opposite of the actual option setting.


Specifically, I'm toggling the "Insert/paste pictures as" between In
Line and In Front. My Close event sets the option to In Front, but
that won't change the button text from "In Line Set" to "In Front Set"
so it matches the option the next time I open Word.


Here's the code I'm using:


Private Sub Document_Close()
'Set Paste Picture option to In Front upon Close
* Options.PictureWrapType = wdWrapMergeFront
End Sub


Sub ImagePaste()
'Toggle Paste Picture option and
'Display current setting on button
* * With CommandBars.ActionControl
* * * * If .Caption = "In Line Set" Then
* * * * * * Options.PictureWrapType = wdWrapMergeFront
* * * * * *.Caption = "In Front Set"
* * * * Else
* * * * * *Options.PictureWrapType = wdWrapMergeInline
* * * * * *.Caption = "In Line Set"
* * * * End If
* * End With
End Sub


BTW...if this sounds silly to most of you, it's as much as exercise in
learning VBA for Word as well as automating an option change that I
use quite often. I can already think of other places where I can use
the ActionControl property, so I'm glad you pointed it out. I'm fairly
proficient with VBA for Excel and now I'm trying to expand my
horizons.


Thanks again!


On 13 Mar, 17:28, Lene Fredborg
wrote:
Have a look at the VBA help on the ActionControl property. You can use the
property to change the Caption (name) or theFaceIDof the control when it is
clicked.


Example:
You want your button to switch between the captions "MyControl On" and
"MyControl Off".
You can obtain this by inserting e.g. the following code in the procedure
that that runs when you click the button:


* * With CommandBars.ActionControl
* * * * If .Caption = "MyControl On" Then
* * * * * * .Caption = "MyControl Off"
* * * * Else
* * * * * * .Caption = "MyControl On"
* * * * End If
* * End With


--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"DerbyDad03" wrote:
I would like to change, via VBA, *either theFaceIDand/or the name on
a custom button that I have assigned to a macro.


Specifically, I want to be able click a specific button, have the code
run, and have the name and/orFaceIDof *that* button change. It is
essentially a toggle button for an option and I want theFaceIDor
name to tell me the current setting of that option.


The button exists and the toggle code runs fine, but I don't know how
to tell VBA which button I want to change.


Can I capture the control number of the button that was pressed via
code or do I have to know it's number beforehand? In either case, how
do I do it?


Thanks!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Cool! Thanks for sticking with me on this one. I learned a bunch -
more than just how to toggle an option.
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I want idMso for "Mailing" Tab button to add this button in custom ribbon tab [email protected] Mailmerge 1 August 6th 07 01:18 PM
I want idMso for "Mailing" Tab button to add this button in custom ribbon tab [email protected] Microsoft Word Help 0 August 6th 07 06:40 AM
I want idMso for "Mailing" Tab button to add this button in custom ribbon tab [email protected] New Users 0 August 3rd 07 03:47 PM
FACEID template no longer works now that I'm in Windows 2000 ... StargateFan New Users 6 March 22nd 06 06:53 AM
Setting custom size problem Bob S Page Layout 0 December 24th 04 03:25 PM


All times are GMT +1. The time now is 09:49 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"