PDA

View Full Version : BOOKMARKING NUMBER STYLES



Greg
09-03-2007, 05:45 AM
Hi all,

Does anyone know if it's possible to bookmark paragraphs with built in numbering "styles"?

I want to use a ref field to recreate those exact paragraphs (and number styles) elsewhere in my document. However, I can only bookmark the text of those paragraphs and not the numbering.

I have applied the same built-in numbering style to those other parts of the document where I want the text to be repeated but I want the numbering to restart in each instance. I haven't been able to achieve it so far.

I should add that I insert the text via a userform and I use field updating. Because there is no way to insert formatted numbering into a userform (that I know of) I must rely on a workaround.

I hope someone has had this problem before and can suggest a solution.

Greg.

fumei
09-03-2007, 07:59 PM
Does anyone know if it's possible to bookmark paragraphs with built in numbering "styles"?Ummm, yes, it is.

However, I can only bookmark the text of those paragraphs and not the numbering.Huh? Really? This is definitely not correct.

Demo attached. Click "Copy ReStart Para" on the top menubar. It executes the following:Sub CopyNumPara()
Dim r As Range
Set r = ActiveDocument.Bookmarks("Test").Range
r.Copy
Selection.EndKey Unit:=wdStory
Selection.PasteAndFormat wdListRestartNumbering
End SubThe first four paragraphs are numbered, AND bookmarked.

The code above copies the bookmark contents to the end of the document. The numbering is preserved, BUT restarted. I believe this is what you are asking about.

Hope this helps.

Greg
09-03-2007, 09:59 PM
Thanks Gerry. I like that.

However, I'm not quite sure how to apply it to my problem.

I had previously bookmarked the paragraphs in my numbered style just as you have with the "Restart" bookmark. I then tried to replicate the bookmarked paragraphs elsewhere in my document using the Ref field.

However, when I do this, only the contents of the paragraphs are repeated whereas the numbering continues on from the last paragraph of the orginal text.

To demonstrate the problem I have added a Ref field to your document (see attached) showing how the numbering increases in the Ref field.

Perhaps you know of a way to get around this or alternatively, to utilise your restart button in some way.

Regards,

Greg.

fumei
09-03-2007, 11:24 PM
The trick is that you have to have the Selection point inside the REF field. It will NOT work if the whole field is selected.

BTW: this can be done very easily manually. Simply put the cursor in the REF field, right click, select Bullets and Numbering, and click ReStart numbering. OK.

Here how you do it by code. Note that this code will process all REF fields in the document and restart ALL of them at 1.Sub ChangeRef()
Dim lfTemp As ListFormat
Dim intContinue As Integer
Dim aField As Field
Set lfTemp = Selection.Range.ListFormat
For Each aField In ActiveDocument.Fields
If aField.Type = wdFieldRef Then
aField.Select
Selection.Collapse Direction:=wdCollapseStart
Selection.Move Unit:=wdCharacter, Count:=4
intContinue = lfTemp.CanContinuePreviousList( _
ListTemplate:=lfTemp.ListTemplate)
If intContinue <> wdContinueDisabled Then
lfTemp.ApplyListTemplate _
ListTemplate:=lfTemp.ListTemplate, _
ContinuePreviousList:=False
End If
End If
Next
End SubDemo doc back atcha! Click the "Tah da!" button on the top menubar.

fumei
09-03-2007, 11:29 PM
BTW: Not sure why you are doing what you are doing, but no doubt you have a reason.

BTW2: the count of 4 that I moved the collapsed Selection is totally random. The point is to move the collapsed Selection inside the field. You could make it 5, or 2.

fumei
09-03-2007, 11:32 PM
BTW....some more...

However, when I do this, only the contents of the paragraphs are repeated whereas the numbering continues on from the last paragraph of the orginal text.Why on earth would it would NOT do this???? It is a numbered list! If you continue ANY numbered list, the numbering continues.....unless you explicitly tell it not do so. Which (hopefully) the code will do for you.

But I am still very curious. WHY would you want the text repeated, but the numbering restart? Seems odd to me.

fumei
09-03-2007, 11:35 PM
Oh, and lastly....with a <grin>.....PLEASE try and be accurate in your posts.

I can only bookmark the text of those paragraphs and not the numbering.Incorrect, or rather....ahem, wrong, wrong, wrong.

The bookmark quite definitely contains the numbering.

Greg
09-04-2007, 02:34 AM
Thanks Gerry.

The reason for doing this (unsuccessfully) is (1) because I cannot apply any number formatting to paragraphs typed into a textbox in my userform and (2) after I type those (numbered) paragraphs into my userform I want them repeated elsewhere in my document.

I had hoped that by formatting the paragraphs in the actual document (and not in the textbox) I would overcome the problem. Not so. If I do this the bookmark misbehaves and "jumps" out of the cell (it is in a table) in the document with disastrous results in the Ref fields.

I am at a complete loss as to what is required to achieve the desired outcome. Do you have any ideas?

Greg.

fumei
09-04-2007, 09:27 AM
Ummm, I am trying to follow this.
If I do this the bookmark misbehaves and "jumps" out of the cell (it is in a table) in the document with disastrous results in the Ref fields.Huh???????


Could you post something that demonstrates this? A bookmark "jumping" out a cell? Say what??

Are the bookmarks already existing, and you are putting the text (entered on the userform) into the bookmark? if so, I suspect you are not getting the text into the bookmark properly.

Which may in fact be a different question that the subject of this thread. I believe I have answered the question, and demonstrated how to do it. Yes, you can have a REF field to a bookmark containing numbered paragraphs, and have that REF field restart at 1.

Greg
09-04-2007, 07:58 PM
Hi again Gerry,

I have attached the recalcitrant document so that you can see what's happening.

Please open the document, and without running any macros, look at where the bookmark "Indorsement" is located on the first page with ref fields in two places on subsequent pages.

Now press the Data Form button on the menu bar to run the userform macro then press OK. You will see that the Indorsement bookmark has relocated itself outside the cell that it normally resides in and the ref fields have created tables within tables.

The cause of the problem has eluded me so far. I hope you can help.

Regards,

Greg.

fumei
09-05-2007, 02:30 PM
Ummmmmmm, yes.....ummmmm, interesting. I see what you mean.

Very weird. Not only does the .End value of the Indorsement bookmark change - WHY???? - but until you actual physically make a new Selection, a bunch of menu items are greyed out. I suspect something is not letting go of memory. I am going to have to go through it line by line, methinks.

Damned if I know.

fumei
09-05-2007, 02:36 PM
Hmmmmmm, I am carefully stepping backwards with UnDo. The Indorsement bookmark is actually removed - this BTW is an effect of the bookmark filling subroutine. It is resized to include the next cell of the table. Why, I am not sure yet.

But in the meantime, why is this particular bookmark being updated? It does not, in fact, have any connection with data from the userform.

I am going to make the userform non-modal so I can look completely through the document as I step through.

fumei
09-05-2007, 02:41 PM
"But in the meantime, why is this particular bookmark being updated? It does not, in fact, have any connection with data from the userform."

Ignore that. I did not know what I was talking about. Yes, it does....doh.

fumei
09-05-2007, 02:51 PM
Oh man, how weird.

If you run the userform twice in a row, the Indorsement bookmark moves and contains the next page!!!! The fees Paid page. It does not cover ANY of the original text of the bookmark. It is actually shuffling forward in the document!

OK, this is ticking me off.

I gonna find the little pixie that is doing this and strangle it. I am sure it is something just....not.....quite....right.

Thanks, I am actually enjoying this.

Greg
09-09-2007, 08:05 PM
Hi again Gerry,

If you have had time to consider this problem you may have discovered that it only happens when the text is fomatted. It does not happen if the text is plain or "Normal".

The problem only arose when I applied my in-built numbering "style" to the text area on the actual document. So, if and when you discovery the "little pixie", I am confident it will have something to do with the numbering style.

Regards,

Greg.