Advanced MS Word Template Design Question: Image swap

P

postal_web

I am trying to do an advanced design for a template in MS Word (2000).

Essentially waht i need to do is have a ready-made WORD TEMPLATE for
users to fill in.

So, obviously there will be style sheets and the like... but there is
one important variable that has to be included and it HAS to be done
with an image swap, not text or radio buttons or check boxes.

I need to make a row of clickable (1-click) images -- like on-off
buttons.

Each image has to be either ON or OFF, much like a javacript
rollover/click for the web, but 1-click will swap the OFF image to the
ON image. (The default is all images off.)

Another click will then swap the ON image to the OFF image.

All of this has to be locked down so that the user can only click the
image to turn it on or off and not be able to replace it with another
image etc...

Please assist if you can.

Thanks in advance!
 
J

Jay Freedman

Hi postal,

For the image swap, look at the way the checkboxes work in the Fax templates
that come with Word. There are three parts to this:

- Two AutoText entries in the template. Each consists of a MacroButton field
whose display "text" is either an empty box or a filled box. In your case it
would be an "on" image or an "off" image (the display isn't limited to
characters). Also, each MacroButton calls a macro that inserts the other
AutoText entry.

- Two macros, one that inserts one of the AutoTexts to replace the
Selection.Text (because clicking on a MacroButton field makes that field the
Selection) and one that inserts the other AutoText. In your case, you also
want an AutoNew() and an AutoOpen macro, each of which sets
Options.ButtonFieldClicks = 1 so the user doesn't have to double-click.

- One of the MacroButton fields already in place in the body of the template
to start the cycle.

In Word 2000, or any version earlier than 2003, the only way to lock these
fields against replacement with other stuff is to put them in a protected
section of a form. In that case, the macros that replace the fields need to
do an unprotect-replace-reprotect cycle.
 
P

postal_web

(e-mail address removed) (postal_web) wrote in message
Thank you! I will give that a try to see if i can get it to work.
 
P

postal_web

Thanks Jay, I will give it a try.

Jay Freedman said:
Hi postal,

For the image swap, look at the way the checkboxes work in the Fax templates
that come with Word. There are three parts to this:

- Two AutoText entries in the template. Each consists of a MacroButton field
whose display "text" is either an empty box or a filled box. In your case it
would be an "on" image or an "off" image (the display isn't limited to
characters). Also, each MacroButton calls a macro that inserts the other
AutoText entry.

- Two macros, one that inserts one of the AutoTexts to replace the
Selection.Text (because clicking on a MacroButton field makes that field the
Selection) and one that inserts the other AutoText. In your case, you also
want an AutoNew() and an AutoOpen macro, each of which sets
Options.ButtonFieldClicks = 1 so the user doesn't have to double-click.

- One of the MacroButton fields already in place in the body of the template
to start the cycle.

In Word 2000, or any version earlier than 2003, the only way to lock these
fields against replacement with other stuff is to put them in a protected
section of a form. In that case, the macros that replace the fields need to
do an unprotect-replace-reprotect cycle.
 
P

postal_web

Jay,

Could you direct me to a good tutorial on MacroButtons... I cannot
seem to find one that will suit this purpose. I have virtually zero
experience with this, but i do have programming experience.

I cannot unlock the fax template to view the macros in their entirety.

I did manage to create an autotext macro where i saw the image (not
text) as an autotext feature as am image in the dialogue box -- but
that is as far as I got.

thank you,
j. gillies
 
P

postal_web

Jay,

Could you direct me to a good tutorial on MacroButtons... I cannot
seem to find one that will suit this purpose. I have virtually zero
experience with this, but i do have programming experience.

I cannot unlock the fax template to view the macros in their entirety.

I did manage to create an autotext macro where i saw the image (not
text) as an autotext feature as am image in the dialogue box -- but
that is as far as I got.

thank you,
j. gillies
 
P

postal_web

Jay,

Could you direct me to a good tutorial on MacroButtons... I cannot
seem to find one that will suit this purpose. I have virtually zero
experience with this, but i do have programming experience.

I cannot unlock the fax template to view the macros in their entirety.

I did manage to create an autotext macro where i saw the image (not
text) as an autotext feature as am image in the dialogue box -- but
that is as far as I got.

thank you,
j. gillies
 
J

Jay Freedman

If you create a new document based on the Professional Fax template and then
open the VBA editor, you should see these two macros:

Sub CheckIt()
ActiveDocument.AttachedTemplate. _
AutoTextEntries("Checked Box").Insert Where:=Selection.Range
End Sub

Sub UncheckIt()
ActiveDocument.AttachedTemplate. _
AutoTextEntries("Unchecked Box").Insert Where:=Selection.Range
End Sub

(I've added the continuation underscores so I could post them here; each
macro actually contains only one statement.)

The AutoText entry named "Checked Box" consists of a MacroButton field with
this code:

{MACROBUTTON UncheckIt <checked box>}

where the <checked box> is actually a box-with-check character (Wingdings
font, character 254).

Similarly, the AutoText entry named "Unchecked Box" consists of a
MacroButton field with this code:

{MACROBUTTON CheckIt <unchecked box>}

where the <unchecked box> is actually an empty box character (Wingdings
font, character 168).

For your project, create the same kind of system, except with your two
images instead of the checked and unchecked boxes. You could even keep the
names of the macros and AutoText entries the same, since they don't appear
anywhere that would be visible to users, but it might be confusing if the
template needs more work in the future.

Here are a couple of references that might help:
http://word.mvps.org/faqs/tblsfldsfms/UsingMacroButton.htm
http://www.addbalance.com/word/download.htm#CheckboxAddIn
 
P

postal_web

Jay,

I was unable to unlock the fax template to view the complete VBScript
and macros.

I WAS able to make an autotext macrobutton as described below -- but i
could not get it to do anything.

Is there a good tutorial to which you could point me on Macrobuttons
so that I can learn how to do this. I have programming experience,
just not very much with VBscript.

thanks in advance,
j. gillies
 
S

Suzanne S. Barnhill

This is not VBScript; it's VBA. You should be able to open the VBA Editor
using Tools | Macro | Macros: Edit or using Tools | Macro | Visual Basic
Editor (Alt+F11). If the macros in the template are disabled, you need to go
to Tools | Macro | Security, choose the Trusted Sources tab, and make sure
that "Trust all installed templates and add-ins" is checked.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
P

postal_web

Just wanted to say a HUGE thank you for your assistance. It totally
works!!

The second link you gave me to the tutorial i found to be the best. In
particular the specific instructions to go back and modyfiy the
autotext entry for each. I was having problems because the changes
were being applied to the global VB values and not to the specific
template.

The only difference between the autotext TEXT and the autotext IMAGE
is that the images are a bit slower than text, but it is absolutely
fine. I managed to get them down to about 2k each.

The only thing i have left to do is lock them so that you can only
click them and not delete them.

The best is that it wokrs on our Macs and Windows machines. I had to
modify the template in Mac to get it to align properly.

Thanks again!
j. gillies
 

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