![]() |
|
#1
|
||||
|
||||
![]()
My code was writing the list to a string variable called str. You need to place the contents of this string into the new document.
Try this version which creates the new doc and puts the contents into it. Code:
Sub List() Dim oDoc As Document, oTarget As Document Dim oRng As Range, oPara As Range Dim str As String, arr() As String, i As Integer Set oDoc = ActiveDocument Set oRng = oDoc.Range With oRng.Find .Forward = True .Wrap = wdFindStop .MatchWildcards = False .Text = "#" Do While .Execute = True Set oPara = oRng.Paragraphs(1).Range Debug.Print oPara.Text arr = Split(oPara.Text, "#") For i = 1 To UBound(arr) str = str & arr(0) & vbCr Next i oRng.Start = oPara.End Loop End With If str <> "" Then Set oTarget = Documents.Add oTarget.Range.Text = str 'put list into new unsaved doc End If End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
1st line of 4-line poem centrally aligned; how to get lines 2-4 to start at same location on page | Swarup | Word | 6 | 09-16-2022 11:07 AM |
![]() |
rgm60527 | Mail Merge | 2 | 02-22-2022 11:13 AM |
![]() |
ozzzy | Word | 2 | 01-21-2021 06:41 AM |
Usability of space between final line of body text and footnote separator line | Swarup | Word | 6 | 07-28-2018 12:51 PM |
Combining IMAP inbox and sent item folders | kenelder | Outlook | 1 | 07-17-2015 02:58 PM |