I tweaked your code a bit Graham, so that it removed the prompt to save the initital document. This initial document is also not required at the end, so have added a couple of lines to close then delete this.
Sub SaveLetter(oDoc As Document)
Dim oTempDoc As Document
Dim oRng As Range
Dim sPath As String
Const strName1 As String = "breakdown report.docx"
Const strName2 As String = "repair plan.docx"
Const strName3 As String = "Temp.docx"
sPath = Environ("USERPROFILE") & "\Repair\Documents\Breakdowns\"
CreateFolders sPath
oDoc.SaveAs2 sPath & strName3 ' Create temporary document
'oDoc.Save
Set oRng = oDoc.Range(0, 0)
Selection.GoTo What:=wdGoToPage, which:=wdGoToNext, Name:="2"
oRng.End = ActiveDocument.Bookmarks("\page").Range.End
Set oTempDoc = Documents.Add(Template:=oDoc.FullName)
oTempDoc.Range.FormattedText = oRng.FormattedText
oTempDoc.Range.Find.Execute findText:="^m", Replacewith:="", Replace:=wdReplaceAll
oTempDoc.SaveAs2 sPath & strName1
oRng.Collapse 0
oRng.End = oDoc.Range.End
Set oTempDoc = Documents.Add(Template:=oDoc.FullName)
oTempDoc.Range.FormattedText = oRng.FormattedText
oTempDoc.SaveAs2 sPath & strName2
'oDoc.Close 0
Documents(strName3).Close ' Close temporary document
Kill sPath & strName3 ' Delete temporary document
lbl_Exit:
Set oTempDoc = Nothing
Set oRng = Nothing
Exit Sub
End Sub
This has on the whole got me to where I want it. The only annoying thing now is that the UserForm insists on showing itself twice more at the end! Here is the code at the start and end of the Fill Form code.
Option Explicit
Private m_oFrm As frmNFAMalCom
Private Sub Document_New()
Set m_oFrm = New frmNFAMalCom
m_oFrm.Show
If m_oFrm.Tag = "Enter" Then FillForm
lbl_Exit:
'Unload m_oFrm
Set m_oFrm = Nothing
Exit Sub
End Sub
Sub FillForm()
Dim oCtrl As Control
Dim oCC As ContentControl
Dim lngIndex As Long
Dim strTC As String
CreatedDate
With m_oFrm
.
.
.
.
.
lbl_Exit:
SaveLetter ActiveDocument
Exit Sub
End Sub
Any help very much appreciated.
Thanks!
Steve