Toggle Bold in a locked form?

D

Doug Robbins

Hi Tonya,

You could do it with a macro assigned to a button on a toolbar or to the
keyboard that unprotected the document, applied the formatting and then
reprotected the document

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
T

Tonya Marshall

Doug said:
Hi Tonya,

You could do it with a macro assigned to a button on a toolbar or to the
keyboard that unprotected the document, applied the formatting and then
reprotected the document

I would like a macro assigned to a button. I've made a template that may
require a paragraph beginning with a colon to be bolded but the rest of
the paragraph not bold so it would be quicker to be able to click a
button just to do that.
 
T

Tonya Marshall

Tonya said:
I would like a macro assigned to a button. I've made a template that may
require a paragraph beginning with a colon to be bolded but the rest of
the paragraph not bold so it would be quicker to be able to click a
button just to do that.
That doesn't sound very clear. What I want is a toggle button to unlock,
bold, lock and then toggle for unbolded. A paragraph may require a
beginning bolded statement with a colon, then back to unbold for the
rest of the paragraph.
It will not always be the case so I would like the user to have the option.
Thanks.
 
D

Doug Robbins

Hi Tonya,

Hi Tonya,

Is the statement that you need to be bold already in the form? If so, the
text to which you want to apply the formatting should be identified by a
bookmark so that the formatting can be applied to the .Range of the bookmark

ActiveDocument.Unprotect
If ActiveDocument.Bookmarks("test").Range.Bold = True Then
ActiveDocument.Bookmarks("test").Range.Bold = False
Else
ActiveDocument.Bookmarks("test").Range.Bold = True
End If
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
T

Tonya Marshall

Doug said:
Hi Tonya,

Hi Tonya,

Is the statement that you need to be bold already in the form? If so, the
text to which you want to apply the formatting should be identified by a
bookmark so that the formatting can be applied to the .Range of the bookmark

ActiveDocument.Unprotect
If ActiveDocument.Bookmarks("test").Range.Bold = True Then
ActiveDocument.Bookmarks("test").Range.Bold = False
Else
ActiveDocument.Bookmarks("test").Range.Bold = True
End If
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset

No. I want the user to be able to add a bolded statement to the form
like below:

(This part is already bold) STATEMENT IN FORM: This part is already in
the formfield and is not bold

I would like them to be able to add this in bold in a new paragraph:
ADDED STATEMENT IN FORM: And continue with unbolded text.

All paragraphs have 12pt. after; all of the statements are in separate
table rows with unbolded form fields following the initial bolded
statement. The rows expand with text so an additional BOLDED STATEMENT:
Can be made. But change to unbolded text following the colon.

I'm having a difficult time making clear what I would like to accomplish.
 
T

Tonya Marshall

Tonya said:
No. I want the user to be able to add a bolded statement to the form
like below:

(This part is already bold) STATEMENT IN FORM: This part is already in
the formfield and is not bold

I would like them to be able to add this in bold in a new paragraph:
ADDED STATEMENT IN FORM: And continue with unbolded text.

All paragraphs have 12pt. after; all of the statements are in separate
table rows with unbolded form fields following the initial bolded
statement. The rows expand with text so an additional BOLDED STATEMENT:
Can be made. But change to unbolded text following the colon.

I'm having a difficult time making clear what I would like to accomplish.

I guess what I'm trying to say is have a bold button that works like the
bold button does in an unlocked document. It would be OK to have 2
buttons: 1 to toggle to bold, 1 to toggle to unbold.
 
J

Jean-Guy Marcil

Tonya Marshall was telling us:
Tonya Marshall nous racontait que :
I guess what I'm trying to say is have a bold button that works like
the bold button does in an unlocked document. It would be OK to have 2
buttons: 1 to toggle to bold, 1 to toggle to unbold.

Here is some basic code to do what you want. Build a toolbar (or add buttons
to an existing one). The buttons on the toolbar should call Sel_Bold,
Sel_Italic or Sel_Underline. Only one button per attribute is necessary.
Unfortunately, with such simple code, you cannot have the same behaviour as
Word's built-in buttons that change appearance depending on the selection.
But it should be clear to a user that if you toggle bold un regular text, it
will be bold, and vice-versa...Although I understand that some user need to
be explained quite a few times...

Good luck!

'_______________________________________
Public myRange As Range
'_______________________________________
Sub Sel_Bold()

Sel_Unprotect

myRange.Bold = wdToggle

Sel_Protect

End Sub
'_______________________________________

'_______________________________________
Sub Sel_Italic()

Sel_Unprotect

myRange.Italic = wdToggle

Sel_Protect

End Sub
'_______________________________________

'_______________________________________
Sub Sel_Underline()

Sel_Unprotect

If myRange.Underline = wdUnderlineNone Then
myRange.Underline = wdUnderlineSingle
Else
myRange.Underline = wdUnderlineNone
End If

Sel_Protect

End Sub
'_______________________________________

'_______________________________________
Sub Sel_Unprotect()

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If

Set myRange = Selection.Range

End Sub
'_______________________________________

'_______________________________________
Sub Sel_Protect()

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, _
Password:=""
End If

myRange.Select

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

Tonya Marshall

Jean-Guy Marcil wrote:
I don't get any error messages and I can see the screen jump a little
when I click the button which points to Sel_Bold, but I don't get bold.
 
J

Jean-Guy Marcil

Tonya Marshall was telling us:
Tonya Marshall nous racontait que :
Jean-Guy Marcil wrote:
I don't get any error messages and I can see the screen jump a little
when I click the button which points to Sel_Bold, but I don't get
bold.

I am sorry, but this code works for me for Word 97 through Word 2003.
Please explain how you installed/used the code I provided because it should
work as is.
If you modified it, post your code modifications.
Also explain what is happening with the document when you are using the
code (protection state, content at cursor, current selection, etc.).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

Tonya Marshall

Jean-Guy, would it be OK if I emailed you the template I have the macro
in? You could look it over and see what I might have messed up. I copied
and pasted your code in it and made no changes to it.
 
T

Tonya Marshall

OK, now I see how it works. Type the text, then select what I want
bolded and click the bold button. I was trying to click the bold button
to start out bold, then click it again to turn it off.
 
J

Jean-Guy Marcil

Tonya Marshall was telling us:
Tonya Marshall nous racontait que :
OK, now I see how it works. Type the text, then select what I want
bolded and click the bold button. I was trying to click the bold
button to start out bold, then click it again to turn it off.

lol
Are you a WordPerfect convert, or WordStar maybe!

You may want to use an appropriate label on your button... "Toggle Selection
Bold", but then it is a bit wordy...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

Tonya Marshall

Jean-Guy Marcil said:
Tonya Marshall was telling us:
Tonya Marshall nous racontait que :


lol
Are you a WordPerfect convert, or WordStar maybe!

You may want to use an appropriate label on your button... "Toggle Selection
Bold", but then it is a bit wordy...
I don't see that other word processors have anything to do with the fact
that I wanted to be able to turn on bold, type some text then turn off
bold. Even Word can do that except, apparently, not in a locked form.
I left the name of the macro, sel_bold on the button and can explain
that sel means select text then click the button.

Thank you for the macro, I appreciate it very much. :)
 
J

Jean-Guy Marcil

Tonya Marshall was telling us:
Tonya Marshall nous racontait que :
I don't see that other word processors have anything to do with the
fact that I wanted to be able to turn on bold, type some text then

In the old WordStar days, and later with WordPerfect (with the Show format
codes, or something like that, I do not remember what it is called) ) you
would insert a tag to signify "Start bold here" and another to signify "end
bold here". If you did not insert the end tag, the whole document would be
bold from the point where the start tag had been inserted.

When you described what you attempted, it reminded me of those days...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

Tonya Marshall

Jean-Guy Marcil said:
Tonya Marshall was telling us:
Tonya Marshall nous racontait que :


In the old WordStar days, and later with WordPerfect (with the Show format
codes, or something like that, I do not remember what it is called) ) you
would insert a tag to signify "Start bold here" and another to signify "end
bold here". If you did not insert the end tag, the whole document would be
bold from the point where the start tag had been inserted.

When you described what you attempted, it reminded me of those days...
I've never done anything like that but HTML will continue bold until you
</b> it. I guess it's kind of like that, eh?
I am a past WordPerfect user but when we got switched to Word at work, I
moaned and groaned a lot, settled into Word and haven't looked back. I
loved WP and now I love Word. Best of 2 worlds there. Learned a lot in
both and I'm still learning. The more I learn the more I understand how
vast Word is and no one can know "all there is to know" about it. I've
barely scratched the surface.
 

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