Solved

paragraph numbering continue on merged document.

Posted on 2014-03-24
11
794 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now