Solved

paragraph numbering continue on merged document.

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

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 35

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

733 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