Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create macro to prompt for bookmark information

Status
Not open for further replies.

wordperfectconvert

Technical User
Feb 16, 2005
18
US
I apologize for my inexperience with VBA. I have used wordperfect for many years and am just now converting. I am basing this question from what I know a wordperfect macro can do.

I have a form that has bookmarks that are propogated from a case management program I am using. However, the case management program doesn't do everything I want.

What I want to happen is for the template to open and have the case management program fill in the bookmarks it can from its information and then start a template macro that will display a dialog box with questions. If I can figure out how to get a simple dialog box, I can build on that.

I want the dialog box to open with a question that asks for the date a document was mailed. I then fill in the date. It then asks the date a follow up letter was mailed and I then fill in that date. The macro would then parse the date so that it would show up in the document as January 1, 2005 (example). The macro would then find the bookmark "fileddate" and put the first date and then find the next bookmark "followupdate" and put the second date.

In wordperfect I also programmed the macro so that if someone left a date blank, the macro would give a prompt and tell them to fill in all the dates and then start over. HELP PLEASE. Thanks.

Bill
 
Hi Bill,

There are a couiple of ways to go about this. Some more details would help to narrow down a solution.

You state "bookmarks". Are these Form Fields - which are also bookmarks? Are they bookmarks that mark a location, or are they bookmarks that marks a range of text?

Depending on EXACTLY how the case management program fills in "bookmarks", here is what I would do.

Use form fields. They can be filled in somewhat easier than "normal" bookmarks.

Use a UserForm. When the document opens, fire the UserForm. Have your questions on the form. It is quite easy to take the information entered on the form and dump it into a form field.

You do not even need two textboxes for your filedate" and "followupdate" information. use one textbox, and a Label above it. Have the label caption be "Date Filed", and you enter the date. On the Textbox_Change event parse through the text from the textbox, format it into whatever date format you want. Store in into a date varaiable.

Then rewrite the label to be "Followup Date". Enter the date into the same textbox, parse and format again. Store it into a second date variable.

On clicking your OK button (which you made) the UserForm writes the variables into the appropriate form fields.

You could even put a calendar on your UserForm and bypass needing to type in dates.

You would fire the UserForm with the Document_Open event.

As for empty bookmarks...if there are form fields, you can have a procedure that also fires at the close of the UserForm that runs through the form fields, and if they are empty stops the UserForm from closing, and relabels the textbox with a question regarding that particular empty form field.

I know that sounds like much, but it is fairly straightforward. If you have not made a UserForm (which is really the "dialog" you mention), check out Help on UserForms.

Also check out Help on Bookmarks, FormFields. You may also want to look at two FAQ I wrote on FormFields in the FAQs for this forum.

Good luck. If you get stuck on details, post back!

Gerry
 
Thanks Gerry for your help. I got the form to work, but I am curious about what you said about bookmarks. When I creat a bookmark in Word, I doesn't let me designate anything more than a name. For example, my sentence reads: "motion was filed on [bookmark:"Date Filed"]." (As you know, the bookmark is simply a vertical line, not this text). When I was creating the macro, I had some trouble with designating where the text would go and settled with the following:

ActiveDocument.Bookmarks("DateDiscoveryFiled").Range.Text = DateFiled.Text

Since I chose range, I guess my bookmark was a text range, but quite frankly it was simply a guess. So...what is the difference between the bookmarks and how do you set them up?

Thank again.

Bill
 
This is why I asked if the bookmarks are locations, or ranges.....or are you using form fields (which also show up as bookmarks) ?????

In any case, bookmarks are Range objects, in that they have a Start and End properties. If they are simply marking a location, Start = End.

However, if you select some text - and it can ANY amount of text - and go Insert > Bookmark and then give a name, that bookmark contains that text.

As you can see that line (which means you have Show Bookmarks ON), try doing the above. Select some text and bookmark it. You will then see the text with a line BEFORE and AFTER it. The range of the text itself is the bookmark. You can make bookmark any length. You can bookmark a whole page, a section, the whole document if you want.

They can also be nested. You can bookmark a passage of text, then make a bookmark of more text around it.

More to the point though, is that replace Range.Text can replace the text all right - but it can delete the bookmark. So yes, you can replace once, but if you repeat the instruction it can fail as the object (the bookmark) no longer exists.

Make sure you test this. If you have problem, and it does do this, post back, because there is a way around it.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top