Is it possible to choose another NORMAL.DOTM in WORD as template for merge documents using VBA?
In WORD I have created a form with several checkboxes. Each checkbox is linked to a document. By linking a VBA code to these boxes, I generate a new WORD document in which the selected documents are imported.
Below is an example of part of the code:
Private Sub CheckboxAAN_Click()
'code voor het aanvinken van alle checkboxen
VoorbladEnInhoudsopgave.Value = True
Voorwoord.Value = True
Inleiding.Value = True
Beschrijving.Value = True
Veiligheid.Value = True
Transport.Value = True
Installatie.Value = True
Bediening.Value = True
Onderhoud.Value = True
Storingen.Value = True
DemontageEnAfdanken.Value = True
LijstAfbeeldingen.Value = True
LijstTabellen.Value = True
Bijlage.Value = True
Private Sub Publiceer_Click()
'code voor maken van nieuw WORD document
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "C:Users\Username\Location\02_Modulaire opbouw"
Set MainDoc = Documents.Add
'code om document samen te stellen
If VoorbladEnInhoudsopgave.Value = True Then
Selection.InsertFile FileName:=("C:\Users\Username\Location\Voorblad en Inhoudsopgave.docx"), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdPageBreak
End If
If Voorwoord.Value = True Then
Selection.InsertFile FileName:=("C:\Users\Username\Location\01_Voorwoor d.docx"), Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdPageBreak
End If
End Sub
|