Solved

paragraph numbering continue on merged document.

Posted on 2014-03-24
11
819 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
[X]
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
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

My experience with Windows 10 over a one year period and suggestions for smooth operation
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
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…

691 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