Hi everyone, I'm having difficulties with the following:
I want to export data from an Excel Sheet to a Word document. The code for that works, but the problem is that specific blocks of code need to be repeated. And that's were it goes wrong.
This is an extract of the code:
Voortgang:
If Controle1 = True Then
GoTo OpmaakKatern2
End If
If Controle2 = True Then
GoTo OpmaakKatern3
End If
OpmaakKatern1:
If Datum1 = Empty Then
Controle1 = False
GoTo Eindsorteren
Else:
Controle1 = True
End If
.TypeParagraph 'Hier start katern1
.TypeParagraph
.Font.Size = 12
.Font.Bold = True
.Font.Underline = True
.TypeText Text:=Katern1 'Hier staat de naam van de katern
.Font.Bold = False
.Font.Underline = False
.TypeParagraph
.Font.Size = 10
.Font.Underline = True
.TypeText Text:="Datum:" 'Hier komt de gesorteerde datum, in te lezen als variabele
.Font.Underline = False
.TypeText Text:=" " & Datum1 'Hier komt de gesorteerde datum, in te lezen als variabele (aanhalingstekens verwijderen voor de variabele)
.TypeParagraph
.Font.Underline = True
.TypeText Text:="Gerealiseerde leerplandoelstellingen:"
.Font.Underline = False
If Katern1 = "Een nieuwe start" Then
GoTo Invulling_EenNieuweStart
ElseIf Katern1 = "Alles heeft zijn tijd" Then
GoTo Invulling_AllesHeeftZijnTijd
ElseIf Katern1 = "De wereld aan je voeten" Then
GoTo Invulling_DeWereldAanJeVoeten
ElseIf Katern1 = "Een levend boek" Then
GoTo Invulling_EenLevendBoek
ElseIf Katern1 = "Drempels" Then
GoTo Invulling_Drempels
ElseIf Katern1 = "Kerstmis" Then
GoTo Invulling_Kerstmis
ElseIf Katern1 = "Confituur of choco" Then
GoTo Invulling_ConfituurOfChoco
ElseIf Katern1 = "Hoe groot is de hemel?" Then
GoTo Invulling_HoeGrootIsDeHemel
ElseIf Katern1 = "Ongelovige Thomas" Then
GoTo Invulling_OngelovigeThomas
ElseIf Katern1 = "Feesten" Then
GoTo Invulling_Feesten
ElseIf Katern1 = "Er is er één jarig!" Then
GoTo Invulling_ErIsErEénJarig
ElseIf Katern1 = "Eén van hart" Then
GoTo Invulling_EénVanHart
ElseIf Katern1 = "Ervoor gaan" Then
GoTo Invulling_ErvoorGaan
ElseIf Katern1 = "Groen gras" Then
GoTo Invulling_GroenGras
ElseIf Katern1 = "RELatie" Then
GoTo Invulling_RELatie
ElseIf Katern1 = "Vele plaatjes" Then
GoTo Invulling_VelePlaatjes
ElseIf Katern1 = "Iedereen fan" Then
GoTo Invulling_IedereenFan
ElseIf Katern1 = "Schattenjacht" Then
GoTo Invulling_Schattenjacht
ElseIf Katern1 = "Lichtbakens" Then
GoTo Invulling_Lichtbakens
ElseIf Katern1 = "Rijke Luis" Then
GoTo Invulling_RijkeLuis
ElseIf Katern1 = "Hemel op aarde" Then
GoTo Invulling_HemelOpAarde
ElseIf Katern1 = "Op bezoek" Then
GoTo Invulling_OpBezoek
End If
And this is an example of an Invulling_-block:
Invulling_ErIsErEénJarig:
If Worksheets("Theo").Rij12_4.Value = True Then
.TypeParagraph
.TypeText Text:=Rij12
End If
If Worksheets("Theo").Rij13_4.Value = True Then
.TypeParagraph
.TypeText Text:=Rij13
End If
If Worksheets("Theo").Rij14_4.Value = True Then
.TypeParagraph
.TypeText Text:=Rij14
End If
If Worksheets("Theo").Rij15_3.Value = True Then
.TypeParagraph
.TypeText Text:=Rij15
End If
If Worksheets("Theo").Rij20_6.Value = True Then
.TypeParagraph
.TypeText Text:=Rij20
End If
If Worksheets("Theo").Rij22_5.Value = True Then
.TypeParagraph
.TypeText Text:=Rij22
End If
If Worksheets("Theo").Rij25_4.Value = True Then
.TypeParagraph
.TypeText Text:=Rij25
End If
If Worksheets("Theo").Rij28_4.Value = True Then
.TypeParagraph
.TypeText Text:=Rij28
End If
GoTo Voortgang
This is how it should work: First the blok 'OpmaakKatern1" is run. In this block, a certain bit of content is picked ip ("Invulling_..."), and at the end of these Invulling_-blocks, there is a GoTo command which sends the code up to a controller ("Voortgang:"), which should check which "OpmaakKatern.." has already been executed. But this doesn't work. It keeps repeating the second OpmaakKatern, instead of moving to the third OpmaakKatern.
Is there anyone who could help me on this one?
Thanks a lot!
Kind regards, Marc