![]() |
|
#4
|
||||
|
||||
|
I doubt anyone would have connected your 'user story categories' with what's in your document. Try:
Code:
Sub ExtractUserStories()
Application.ScreenUpdating = False
Dim DocSrc As Document, DocTgt As Document, Tbl As Table, Rng As Range
Dim ArrRls, i As Long, r As Long, bExp As Boolean
ArrRls = Array("Profit Analyzer", "Deal Manager", "Price Manager")
Set DocSrc = ActiveDocument
For i = 0 To UBound(ArrRls)
Documents.Add (DocSrc.AttachedTemplate.FullName)
ActiveDocument.SaveAs2 FileName:=DocSrc.Path & "\" & ArrRls(i) & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
Next
With DocSrc.Range
.ListFormat.ConvertNumbersToText
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Style = wdStyleHeading1
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
Set Rng = .Paragraphs(1).Range
Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\HeadingLevel")
For i = 0 To UBound(ArrRls)
For Each Tbl In Rng.Tables
bExp = False
With Tbl
If InStr(.Range.Text, ArrRls(i)) > 0 Then
Set DocTgt = Documents(ArrRls(i) & ".docx"): bExp = True
With DocTgt
With .Range
.Characters.Last.FormattedText = Rng.FormattedText
.InsertAfter Chr(12)
End With
.Save
DoEvents
End With
Exit For
End If
End With
Next
Next
.Start = Rng.End
.Find.Execute
Loop
End With
For i = 0 To UBound(ArrRls)
Documents(ArrRls(i) & ".docx").Close True
Next
DocSrc.Undo (1)
Set Rng = Nothing: Set DocTgt = Nothing: Set DocSrc = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| data mining |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I have 20 page word document with a footer. Can i change page # 10 footer only? | aligahk06 | Word | 2 | 10-25-2017 04:53 AM |
| Running Head AND Page Number on First Page of Document (for APA Format) with Word 2003 | DBinSJ | Word | 3 | 11-23-2016 11:52 AM |
| Adding a link into a word document that when pressed, takes user to a page within the same document | yan89 | Word | 1 | 04-29-2016 01:54 PM |
| 2 page document printing problem, text from page 1 in layout of page 2 when printed | laurawether45 | Word | 1 | 08-02-2012 07:03 AM |
600 page document in word 2007
|
ggun123 | Word | 3 | 08-23-2011 06:54 AM |