我遇到以下困难:
我想将Excel工作表中的数据导出到Word文档。它的代码有效,但问题是需要重复特定的代码块。这就是它出错了。
这是代码的摘录:
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
这是一个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
这是它应该如何工作: 首先运行blok'OpmaakKatern1'。在这个块中,选择一些内容ip(“Invulling _...”),并在这些Invulling_-blocks的末尾,有一个GoTo命令发送代码到控制器(“Voortgang:”),它应该检查哪个“OpmaakKatern ..”已被执行。 但这不起作用。它不断重复第二个OpmaakKatern,而不是转移到第三个OpmaakKatern。
有没有人可以帮我这个?
非常感谢!
亲切的问候, 马克
答案 0 :(得分:0)
你确定在OpmaakKatern2区块中将某条线设置为Controle2为True吗?
Controle2 = True