E
EllenM
Hello,
I have a macro that breaks up a large txt file into smaller files.
Everything is fine, except that it saves the smaller files as .docs, when I'd
like them to be saved as .txt files.
The code that I think needs fixing is:
nDoc.SaveAs Format(l, "00000") & ".doc"
My complete macro is as follows:
Sub macro8b()
Dim l As Long ' number of new docs to be created
Dim p As Long ' Number of paragraphs in source doc
Dim nDoc As Document ' a new doc
Dim rDcm As Range ' the source documents range
Set rDcm = ActiveDocument.Range
p = rDcm.Paragraphs.Count
While p > 1
l = l + 1
Selection.GoTo _
What:=wdGoToLine, _
Which:=wdGoToAbsolute, _
Count:=3500
With Selection.Find
.Execute FindText:="Doctype"
End With
Selection.MoveUp Unit:=wdLine, Count:=1
rDcm.Start = 0
rDcm.End = Selection.Bookmarks("\line").Range.End
Set nDoc = Documents.Add
nDoc.Range.InsertAfter rDcm.Text
rDcm.Delete
nDoc.SaveAs Format(l, "00000") & ".doc"
nDoc.Close
Set rDcm = ActiveDocument.Range
p = rDcm.Paragraphs.Count
Wend
End Sub
Thanks in advance for your help!!
EllenM
I have a macro that breaks up a large txt file into smaller files.
Everything is fine, except that it saves the smaller files as .docs, when I'd
like them to be saved as .txt files.
The code that I think needs fixing is:
nDoc.SaveAs Format(l, "00000") & ".doc"
My complete macro is as follows:
Sub macro8b()
Dim l As Long ' number of new docs to be created
Dim p As Long ' Number of paragraphs in source doc
Dim nDoc As Document ' a new doc
Dim rDcm As Range ' the source documents range
Set rDcm = ActiveDocument.Range
p = rDcm.Paragraphs.Count
While p > 1
l = l + 1
Selection.GoTo _
What:=wdGoToLine, _
Which:=wdGoToAbsolute, _
Count:=3500
With Selection.Find
.Execute FindText:="Doctype"
End With
Selection.MoveUp Unit:=wdLine, Count:=1
rDcm.Start = 0
rDcm.End = Selection.Bookmarks("\line").Range.End
Set nDoc = Documents.Add
nDoc.Range.InsertAfter rDcm.Text
rDcm.Delete
nDoc.SaveAs Format(l, "00000") & ".doc"
nDoc.Close
Set rDcm = ActiveDocument.Range
p = rDcm.Paragraphs.Count
Wend
End Sub
Thanks in advance for your help!!
EllenM