Placing Building Blocks at Bookmarks
Hello,
I have just created this UserForm called EVT. The purpose of it is to ask users to choose a type of document and then select the document parts that they want to insert in the document.
So I have created a number of Building Blocks (BB) that would fit in at a number of bookmarks. In a nutshell and schematically, BB1/Doc1 through to BB1/Doc6 goes to Bookmark1, BB2/Doc1 to BB2/Doc6 goes to Bookmark2, bearing in mind that each time there's only one BB for each level and for each give Doc. I am not sure I am making myself clear.
also, one type of document requires a landscape paper orientation.
The result I have achieved is the conditional appearance of the selected frame (one frame per document type). I cannot seem to get the condition paper orientation nor the BB insertion.
Thanks for your help.
Paskie.
This is the code I have come up with so far:
Code:
Private Sub CommandButtonCreate_Click()
With ActiveDocument.PageSetup
If ComboBoxDocType.Value = "Compilation of Comments" Then
.Orientation = wdOrientLandscape
.PaperSize = wdPaperA4
.TopMargin = CentimetersToPoints(2.54)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
Else
.Orientation = wdOrientPortrait
.PaperSize = wdPaperA4
.TopMargin = CentimetersToPoints(2.54)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
End If
End With
Me.Repaint
EVT.Hide
End Sub
Code:
Private Sub userform_initialize()
ComboBoxDocType.List = Array("Compilation of Comments", "Lessons Observation", "EUMC Meeting Documents", "Military Advice", "Initiating Military Directive")
ListBoxCoC.List = Array("General Comments", "Specific Comments")
ListBoxEUMC.List = Array("Adoption of the Agenda (Provisional Agenda)", "Adoption of the Agenda (Outcome of Proceedings)", "Agenda Point", "Agenda Point (Possible)", "Information (Provisional Agenda)", "Information (Outcome of Proceedings)", "Next Meeting", "A.O.B. at 28", "Operation ALTHEA", "A.O.B. at 27")
ListBoxMA.List = Array("References", "INTRODUCTION AND AIM", "CONSIDERATIONS", "RECOMMENDATION(S)")
ListBoxIMD.List = Array("References", "SITUATION", "MISSION", "DIRECTION", "ANNEXES")
End Sub
Code:
Private Sub ComboBoxDocType_Change()
If ComboBoxDocType.Value = "Compilation of Comments" Then
FrameLO.Visible = False
FrameCoC.Visible = True
FrameEUMC.Visible = False
FrameMA.Visible = False
FrameIMD.Visible = False
End If
If ComboBoxDocType.Value = "Lessons Observation" Then
FrameLO.Visible = True
FrameCoC.Visible = False
FrameEUMC.Visible = False
FrameMA.Visible = False
FrameIMD.Visible = False
End If
If ComboBoxDocType.Value = "EUMC Meeting Documents" Then
FrameLO.Visible = False
FrameCoC.Visible = False
FrameEUMC.Visible = True
FrameMA.Visible = False
FrameIMD.Visible = False
End If
If ComboBoxDocType.Value = "Military Advice" Then
FrameLO.Visible = False
FrameCoC.Visible = False
FrameEUMC.Visible = False
FrameMA.Visible = True
FrameIMD.Visible = False
End If
If ComboBoxDocType.Value = "Initiating Military Directive" Then
FrameLO.Visible = False
FrameCoC.Visible = False
FrameEUMC.Visible = False
FrameMA.Visible = False
FrameIMD.Visible = True
End If
End Sub
Code:
Sub InsertExistingBuildingBlock()
Dim EVT_Stage01 As Template
Dim GeneralComments As BuildingBlock
Dim SpecificComments As BuildingBlock
Dim Table As BuildingBlock
Dim OoPAdoptionofAgenda As BuildingBlock
Dim AgendaPoint As BuildingBlock
Dim AgendaPointPossible As BuildingBlock
Dim OoPInformation As BuildingBlock
Dim OoPNextMeeting As BuildingBlock
Dim AOBat28 As BuildingBlock
Dim OpALTHEA As BuildingBlock
Dim AOBat27 As BuildingBlock
Dim ProvAgendaAdoption As BuildingBlock
Dim InformationAgenda As BuildingBlock
Dim ProvAgendaNotes As BuildingBlock
Dim References As BuildingBlock
Dim SITUATION As BuildingBlock
Dim MISSION As BuildingBlock
Dim DIRECTION As BuildingBlock
Dim Annexes As BuildingBlock
Dim INTRODUCTION As BuildingBlock
Dim CONSIDERATIONS As BuildingBlock
Dim RECOMMENDATIONS As BuildingBlock
Set EVT_Stage01 = ActiveDocument.AttachedTemplate
If ComboBoxDocType.Value = "Compilation of Comments" Then
If ListBoxCoC.Value = "General Comments" Then
Set GeneralComments = objTemplate.BuildingBlockTypes(wdTypeCustomQuickParts).Categories("Compilation of Comments").BuildingBlocks("GeneralComments")
GeneralComments.Insert Where = ActiveDocument.Bookmarks("EVTBookMark01").Range, RichText = True
ElseIf ComboBoxDocType.Value = "Lessons Observed" Then
Set Table = objTemplate.BuildingBlockTypes(wdTypeCustomQuickParts).Categories("Lesson Observation").BuildingBlocks("Table")
Table.Insert Where = ActiveDocument.Bookmarks("EVTBookMark01").Range, RichText = True
End If
End If
If ListBoxCoC.Value = "Specific Comments" Then
Set SpecificComments = objTemplate.BuildingBlockTypes(wdTypeCustomQuickParts).Categories("Compilation of Comments").BuildingBlocks("SpecificComments")
SpecificComments.Insert Where = ActiveDocument.Bookmarks("EVTBookMark02").Range, RichText = True
End If
End Sub