Solved

paragraph numbering continue on merged document.

Posted on 2014-03-24
11
789 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

20 Experts available now in Live!

Get 1:1 Help Now