I have made three templates; one Agreement, one pricelist appendix and one condition appendix.
I have a Word form with VBA code that sometimes need one or two of the extra appendix merged and sometimes not. How do I make a new document that, if necessary, adds the pricelist and/or the agreement at the end?
I have find a code that merges all documents in one folder, but to get that to work I must do all these parts:
1. Make all temporary documents from the different templates
2. Make a temporary folder
3. Save the documents in the folder
4. Merge the documents
5. Save the new document in the folder I need it in
6. Delete the documents in the temporary folder
7. Delete the temporary folder
Is there any way to do this without making temporary files and folder?
This is the code i found:
Code:
Sub MergeDocuments()
Application.ScreenUpdating = False
MyPath = ActiveDocument.Path
MyName = Dir(MyPath & "\" & "*.docx")
i = 0
Do While MyName <> ""
If MyName <> ActiveDocument.Name Then
Set wb = Documents.Open(MyPath & "\" & MyName)
Selection.WholeStory
Selection.Copy
Windows(1).Activate
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.Paste
i = i + 1
wb.Close False
End If
MyName = Dir
Loop
Application.ScreenUpdating = True
End Sub