J
Jason Logue
Hi, I currently have part of my code that separates an ascii text file
into multiple word docs by the paragraph marker. My code retrieves a
certain number in the file and saves the document with that number as
the name. There is one extra step I would like to add, but I am not
sure how to add it. I need the code to insert a file into the
beginning of each newly created document. This inserted file is going
to be the header file; each separate file will eventually be a data
source for a shell document. Would you anyone have any good
suggestions for this? Here is the code I have for the number grab,
file separation and saving of each file.
Dim fname As String, i As Integer, Source As Document, Target As
Document
Set Source = ActiveDocument
For i = 1 To Source.Paragraphs.Count
Set Target = Documents.Add
Target.Range = Source.Paragraphs(i).Range
Selection.Find.Execute Replace:=wdReplaceAll
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.MoveUntil Cset:="."
Selection.MoveUntil Cset:=","
Selection.MoveLeft Unit:=wdCharacter, Count:=12,
Extend:=wdExtend
fname = Selection
Target.SaveAs FileName:=fname & ".doc"
Target.Close
Set Target = Nothing
Next i
Set Source = Nothing
End Sub
TIA - Jason
into multiple word docs by the paragraph marker. My code retrieves a
certain number in the file and saves the document with that number as
the name. There is one extra step I would like to add, but I am not
sure how to add it. I need the code to insert a file into the
beginning of each newly created document. This inserted file is going
to be the header file; each separate file will eventually be a data
source for a shell document. Would you anyone have any good
suggestions for this? Here is the code I have for the number grab,
file separation and saving of each file.
Dim fname As String, i As Integer, Source As Document, Target As
Document
Set Source = ActiveDocument
For i = 1 To Source.Paragraphs.Count
Set Target = Documents.Add
Target.Range = Source.Paragraphs(i).Range
Selection.Find.Execute Replace:=wdReplaceAll
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.MoveUntil Cset:="."
Selection.MoveUntil Cset:=","
Selection.MoveLeft Unit:=wdCharacter, Count:=12,
Extend:=wdExtend
fname = Selection
Target.SaveAs FileName:=fname & ".doc"
Target.Close
Set Target = Nothing
Next i
Set Source = Nothing
End Sub
TIA - Jason