Re: Button adding Section of Text
- From: Dax Arroway <DaxArroway@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 26 Jul 2009 23:20:01 -0700
Very nice. Yes, this is what I'm looking for, however, I actually want to
insert the text section into the middle of the document not at the bottom
(there are signature lines w/date lines and other items in the bottom that
need to stay in the bottom). I'm also looking for a way to call the Macro by
clicking on a line of text ("Add Problem") if that's possible. (I'm liking
the idea of text because I could format it as hidden text so when it's
printed, there won't be a Add Another Problem button at the bottoms of the
problems.) So the doc would look like this:
Header
Beginning text
Problem Section
Link to add another problem section
Bottom of doc text
Footer
You are correct in your assumptions below and I've named the Macro and
AutoText to match so that all works. I also password protected the document
and found how and where to include it in the code and also a way of
protecting the code from prying eyes. That's all good. If I can get the
positioning down, I'll be set. Something like: insert.autotext
where=link"Add Problem" (I know that's totally wrong but you know what I
mean).
Thanks so much for helping me out! Love ya!
PS: Thanks also for the SEQ suggestion. That works great.
--
I would give my left hand to be ambidextrous!
"Jay Freedman" wrote:
Set up the unfilled problem section and save it as an AutoText entry in the.
template for the document. (Note: don't try to make multiple copies from a
document-- that's what a template is for.) See
http://www.word.mvps.org/FAQs/Customization/AutoText.htm for details.
Since you're using dropdowns, form fields, and checkboxes, I assume you're
protecting the document for forms. I'll also assume you named the AutoText entry
"NewProblem" although it could be any unique name up to 32 characters.
The macro is fairly simple. The task is to (a) unprotect the document, (b)
insert the AutoText entry at the end of the document, and (c) reprotect the
document.
Sub NewProblem()
Dim oRg As Range
With ActiveDocument
' unprotect
If .ProtectionType <> wdNoProtection Then
.Unprotect
End If
' insert the entry
Set oRg = .Range
oRg.Collapse wdCollapseEnd
.AttachedTemplate.AutoTextEntries("NewProblem").Insert _
Where:=oRg, RichText:=True
' reprotect
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With
End Sub
Finally, I'd suggest using a SEQ field instead of a dropdown to display the
problem number, eliminating one task for the user (and eliminating the chance
for them to pick the wrong number). To make sure the SEQ fields display
correctly, add this line just before the "reprotect" comment:
.Fields.Update
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
On Sun, 26 Jul 2009 12:54:11 -0700, Dax Arroway
<DaxArroway@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I'm looking for a way to add link or button to insert a group of text in my
Word document. I'm sure there's a way but I'm not sure of the approach.
Please help.
I have a form which describes customer problems by number. Some customers
only have one problem, others have up to 8. My form has a section for one
problem which says, "Problem #" followed by a dropdown menu to select the
problem number. This is followed by a form field where the client can
include a description of the problem (to control printed space this is inside
a table). And lastly is a list of options bulleted with checkboxes which
describe the follow up (need f/u, closed, needs resolution, etc.).
What I'm looking for is a button to follow this labled "Add New Problem"
which, when clicked would paste the above section again including text, form
fields, dropdown menues, and table. In other words, there's only one problem
section on the document but if a cusotmer had 5 problems, the client could
fill out the information for one problem, click the Add New Problem
button/link to add another problem section, fill that out, and click the
button again, and so on and so forth until all the problems were populated in
the document.
(I think that makes sense. Please let me know if more description is
needed.)
So, I'm looking for a way to do this. Any links to documents describing how
to do it would be helpful or the code itself. I'm guessing this could be
done with a Macro??? but I'm not the best Macro writter so any detailed help
is greatly appreciated. Maybe Visual Basic, but then again, I know very
(emphasis on the very) little about writting Visual Basic (last time I looked
at it we were on VB6 before the turn of the century).
I'm writting this in Word 03 in a Windows environment.
WhatChaGot? Thanks in advance for any help.
- Follow-Ups:
- Re: Button adding Section of Text
- From: Jay Freedman
- Re: Button adding Section of Text
- References:
- Button adding Section of Text
- From: Dax Arroway
- Re: Button adding Section of Text
- From: Jay Freedman
- Button adding Section of Text
- Prev by Date: Re: How to set no repeat bakground image in word
- Next by Date: For Next Statement with a Combo Box
- Previous by thread: Re: Button adding Section of Text
- Next by thread: Re: Button adding Section of Text
- Index(es):
Relevant Pages
|