Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

paragraph numbering continue on merged document.

Posted on 2014-03-24
11
807 Views
Last Modified: 2014-04-09
I've got a couple of documents that I merged into 1 using a VBA Macro on Microsoft Word 2007.

Application.Selection.EndKey (Word.WdUnits.wdStory)
ActiveWindow.ActivePane.View.Type = wdOutlineView
ActiveDocument.Subdocuments.AddFromFile ("C:\1.docx")
ActiveDocument.Subdocuments.AddFromFile ("C:\2.docx")
ActiveWindow.View.Type = wdPrintView

Open in new window



Document 1 and 2 look more or less the same.

1. sadfdsfdsfa
2. asddfsdsfa
3. asdfdsfdsaf
.....
.....


My problem is that the 2nd document continue the paragraph numbering where the 1st one stops.  I don't want it to continue, but keep the paragraph numbering as it is saved in the document.
Any ideas?
0
Comment
Question by:koossa
  • 5
  • 3
  • 3
11 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39949948
Insert a section break after the first document, then restart/remove numbering.

Selection.InsertBreak Type:=wdSectionBreakNextPage

HTH,
Dan
0
 

Author Comment

by:koossa
ID: 39950056
The problem is, the 2nd document could be 100 pages long and the numbering could be anywhere in the document.
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39950091
OK, let's clarify the terms a bit: paragraph numbering are numbered lists (those that you get clicking the button next to "Bullets") or line numbers that you get from Page Layout->Line numbers?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:koossa
ID: 39950107
Yes, I'm talking about the paragraph numbering (button next to "Bullets")
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39950130
You have here an interesting article about number restarting in VBA: http://word.mvps.org/faqs/numbering/ListRestartFromVBA.htm

Basically you run MarkRestarts() on both documents to add a bookmark on every paragraph that starts with 1.

After the merge of the documents, you run ReapplyRestarts() to reset to 1 every paragraph with a bookmark.

HTH,
Dan
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39950311
Here is a way to use Word's RestartNumbering command:
    Dim subdoc As Document
    With ActiveDocument
        For Each subdoc In ActiveDocument.Subdocuments
            subdoc.Paragraphs.First.SelectNumber
            Application.Run "restartNumbering"
        Next subdoc
    End With

Open in new window

0
 

Author Comment

by:koossa
ID: 39950327
I get a type mismatch on this line.

For Each subdoc In ActiveDocument.Subdocuments
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39950335
I'll test it again
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39950350
The old problem of last minute editing. I inserted the first line after testing, but before posting.
    Dim subdoc As Subdocument
    With ActiveDocument
        For Each subdoc In ActiveDocument.Subdocuments
            subdoc.Paragraphs.First.SelectNumber
            Application.Run "restartNumbering"
        Next subdoc
    End With

Open in new window

0
 

Author Comment

by:koossa
ID: 39955184
subdoc.Paragraphs.First.SelectNumber

Open in new window


Method or data member not found on the above line (highlighting Paragraphs)
0
 

Author Closing Comment

by:koossa
ID: 39988166
Thank you
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
Outlook Free & Paid Tools
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question