View Full Version : Quickly Select and Delete groups of standard clauses out of a long document
KennStewart
09-11-2010, 10:00 AM
At some point I did quite a bit of VBA work in Excel (former beancounter) but I am absolutely clueless with automating Word.... HELP ME MR WIZARD!!!!
I am trying to set up a document where I can designate at the beginning of each paragraph or groups of paragraphs whether that section of text should remain or go away. I am starting to write contracts with a bunch of standard language where I need to be able to quickly identify then delete portions that don't apply and then save the newly shortened writing.
I have seen this done where someone hits an f key (f9?, F11?) moving down the document to preset fields (prompts?, bookmarks?) at the top of each group of text and answering "Y" (for retain) or "N" (for delete) to decide whether the following block of text should remain. At the end of document, a hot key invokes a macro to run and remove all text following an "N" indicator as well as removing the little preset field indicators (if they even actually appear on the document- I can't remember) so the document looks legit.
The good part about this method is I can go through the selections one more time before pulling the trigger on the portions to delete. Of course, then the document is saved/renamed with only the stuff I need for that document.
Any help on this is greatly appreciated.
Kenn
Tinbendr
09-12-2010, 05:46 AM
Welcome to VBA Express!
Some good reading here (http://addbalance.com/usersguide/).
Also investigate autotext. Autotext is a short-hand for Word. You can include just about anything in a autotext entry, then using a predefined short-cut word, bring it all back. There are some autotext entries preloaded in Word. (In 2007-2010, it's called building blocks.)
You can, of course, write macros to selectively show or hide text located in bookmarks. Until you can provide a sample document with specific questions, then we're not going to be much help.
fumei
09-13-2010, 02:14 PM
There are a huge number of ways to go about this.
The fact that you wish to be able to reverse things is crucial.
You can go a additive process, or a reductive process.
Either adding things, or taking things away.
This has to be fully worked out. AutoText can put things in, but once in, they are not defined (so can not easily be removed).
If your "chunks" are defined as bookmarks, they can either be removed (by a checkbox - the same as your "Y" or "N"), however, if they are removed by the decision of the checkbox (Y-N), then they are gone.
However, again, if it is UNchecked, you could use Autotext to put them back in.
Or, a "NO", could make th echunk hidden text. I am not a fan of hidden text. It is too easy to see it. Click Show/Hide and voila, you can see it. Maybe that would work for you.
The first decision is again is it to be additive or reductive? Do you want to see everything first, and take things away?
KennStewart
09-13-2010, 06:36 PM
Thank you both very much for the help. Here is a sample of the template I am starting with.. I can't provide the real text as I don't own it, my employer does so I changed it up. I just want to have a template with everything already there and then as Gerry mentioned, reduce it down from there, then save the reduced sample as a new file and retain the orignal for the next deal.
Thanks again.
Kenn
bstephens
09-14-2010, 12:18 AM
these may be useful to you... especially if you use brackets around the standard clauses.
http://benread.net/tools/Macros-Word-General.htm
http://benread.net/tools/Macros-Word-Annotation.htm
fumei
09-14-2010, 12:43 PM
As stated there are a number of ways of going about this. bstephens link shows a very useful route.
"then save the reduced sample as a new file and retain the orignal for the next deal."
Hmmmm. This should be done as a real template (.dot). Then this is simply not an issue. The original is never in play, only a clone of it.
Shortened demo attached. Two routes here. The first two "chunks" have ActiveX optionbuttons (Keep and Delete). If you do not explicitly select Delete, its associated chunk is NOT deleted.
The second route is using a formfield - this is for the third "chunk". This is a sort of reverse decision. You MUST check the box to keep the chunk, otherwise the chunk is deleted.
I do not really recommend this route, as it is liable to error. Someone can forget to check the box. Mind you, you can add error trapping to check - if a checkbox is not checked you can explicitly ask to confirm. OR, you can have it the the checked box deletes the chunk (rather than keeping the chunk).
What can I say? Other than to reiterate that you need to make decisions on how - exactly - you want to do it.
Anyway, because it uses a formfield the document must be protected for forms. If you went the ActiveX optionbutton route (and not use formfields at all) then you would not need to do this.
There is no Yes/No button. A single button performs one set of instructions. Optionbuttons (grouped) have the advantage of only allow ONE of the buttons to be True. If Keep is True, the Delete must be False.
You could go a single button route, like the formfield. If selected (True) keep the chunk...or delete the chunk, whichever you decide. But you have to decide.
The commandbutton (Do It) tests the Delete optionbuttons. If True, the chunk is deleted out of the document via bookmarks (Chunk_A, Chunk_B, Chunk_C...). The bookmarks include the buttons themselves.
Once deleted by the commandbutton they are gone..
KennStewart
09-14-2010, 09:44 PM
Thank you very much. The code was most helpful and very familiar. I get the labelling of bookmarks as chunks now and code is very straight forward. One last question and I think I am good to go. What is the protocol to insert visual basic buttons upon various places in a Word 2003 document (i.e ? the numbered optionButtons and the macrobutton) and is there a property table for each button to make it invisible when printing or pasting text? You guys are great.
fumei
09-15-2010, 09:59 AM
I prefer ActiveX commandbuttons, but you can also use MACROBUTTON. ActiveX commandbuttons have a security level factor that MACROBUTTON does not.
The button in the demo is an ActiveX control. Use the Controls toolbar. View > Toolbars and select Controls.
I do not know what you mean by "numbered optionButtons".
"is there a property table for each button to make it invisible when printing or pasting text?"
ActiveX controls in the document do NOT - repeat NOT - have a Visible property. Unlike controls on a userform, which do. To not show controls during Print, check the "Print data only for forms" checkbox in Tools > Options > Print.
I do not know what you mean regarding "pasting text?" What is the issue?
fumei
09-15-2010, 11:29 AM
Since this appears to be in the legal world, you may want to look at
http://www.infoware.ca/content/infoframe.htm?docassem.asp
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.