Page 1 of 2 1 2 LastLast
Results 1 to 20 of 27

Thread: Placing Building Blocks at Bookmarks

  1. #1

    Post 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:

    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
    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
    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
    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
    Last edited by SamT; 12-16-2017 at 10:51 AM.

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    None of the Declared Building Blocks in the last sub have any Values. It won't work with Null Building Blocks.

    I refactored one sub for brevity and clarity. The first sub can be refactored similarly.
    Private Sub ComboBoxDocType_Change()
    
            FrameLO.Visible = False
            FrameCoC.Visible = False
            FrameEUMC.Visible = False
            FrameMA.Visible = False
            FrameIMD.Visible = False
    
    With Me 'Added this Line and subsequent Dots (".") dunno if "ME' Is appropriate
    Select Case .ComboBoxDocType.Value
        Case "Compilation of Comments":       .FrameCoC.Visible = True
        Case "Lessons Observation":           .FrameLO.Visible = True
        Case "EUMC Meeting Documents":        .FrameEUMC.Visible = True
        Case "Military Advice":               .FrameMA.Visible = True
        Case "Initiating Military Directive": .FrameIMD.Visible = True
    End Select
    End With
    End Sub
    I also moved this thread to the Word Help Forum.
    Last edited by SamT; 12-16-2017 at 11:11 AM.
    Please take the time to read the Forum FAQ

  3. #3
    The orientation part of the macro does work but is affected by the order of processing

    Private Sub CommandButtonCreate_Click()
        With ActiveDocument.PageSetup
            .PaperSize = wdPaperA4
            .TopMargin = CentimetersToPoints(2.54)
            .LeftMargin = CentimetersToPoints(2.54)
            .RightMargin = CentimetersToPoints(2.54)
            .BottomMargin = CentimetersToPoints(2.54)
        End With
        InsertExistingBuildingBlock
        If ComboBoxDocType.ListIndex = 0 Then
            If Selection.PageSetup.Orientation = 0 Then
                Selection.PageSetup.Orientation = 1 'landscape
            End If
        Else
            Selection.PageSetup.Orientation = 0 'portrait
        End If
        Me.Hide
    End Sub
    Some of your conditional logic cannot work e.g. ComboBoxDocType.Value = "Lessons Observed" does not exist - the value is "Lessons Observation". In any case the line containing it can never work as that condition never exists. There are only three states for ComboBoxDocType.Value so you could use case statements, and I would suggest using the listindex and then the spelling doesn't matter e.g.

    Sub InsertExistingBuildingBlock()
        Select Case ComboBoxDocType.ListIndex
            Case Is = 0 'First item in list
                If ListBoxCoC.Text = "General Comments" Then
                    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "GeneralComments"
                End If
            Case Is = 1 'Second item in list
                AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "Table"
                If ListBoxCoC.Text = "Specific Comments" Then
                    AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "SpecificComments"
                End If
            Case Else 'Nothing selected
        End Select
    End Sub
    The macro calls the folllowing function to fill the bookmarks

    Public Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
    'Graham Mayor - http://www.gmayor.com - Last updated - 17 Dec 2017
    'strBMName is the name of the bookmark to fill
    'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate
    'strAutotext is the name of the autotext entry
    Dim orng As Range
        On Error GoTo lbl_Exit
        With ActiveDocument
            Set orng = .Bookmarks(strbmName).Range
            Set orng = oTemplate.AutoTextEntries(strAutotext).Insert _
                       (Where:=orng, RichText:=True)
            .Bookmarks.Add Name:=strbmName, Range:=orng
        End With
    lbl_Exit:
        Exit Sub
    End Sub
    I have no idea what your other list boxes do - but the principles will be similar.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    Jumping in late here to offer my own two cents (pence) :-). I use buildingblocks (AutoText) quite a bit and employ several of the Galleries and custom categories. With that practice, it is possible to have two or more building blocks defined such that Word may or may not know the correct BB to insert using the old AutoTextEntries method. Therefore, I try to explicitly define the BuidlingBlock to define by template, gallery, catefory and name.

    I've also included my code for insert at a content control vice bookmark:

    Sub InsertDemos()
    '  'For building blocks in the default template "Normal.dotm", default Gallery "AutoText"
    '  'and default Category "General" simmply pass the bookmark and building block names as arguments e.g.,:
    '  BBtoBM "BMTarget_Header", "GKM"
    '  'For building blocks in the document attached template (other than Normal.dotm),
    '  'pass the bookmark name, building block name and ThisDocument.AttachedTemplate.Name as arguments.
    '  'If the gallery or category is not the default, pass them as well e.g.,
    '  BBtoBM "BMTarget_1", "Car", ThisDocument.AttachedTemplate.Name, 29, "Classic"
    '  'For building blocks in a named tempalte (not Normal.dotm or not the attached template), pass the template
    '  'name (without extenstion) e.g., a Table of Contents from the built in building blocks.
    '  BBtoBM "BMTarget_1", "Manual Table", "Built-in Building Blocks", 14, "Built-in"
      'Similar process using a titled content control.
      BBtoCC "CCTarget_1", "GKM"
      BBtoCC "CCTarget_Header", "Car", ThisDocument.AttachedTemplate.Name, 29, "Classic"
      BBtoCC "CCTarget_1", "Manual Table", "Built-in Building Blocks", 14, "Built-in"
      BBtoCC "CCTarget_1", "Car", ThisDocument.AttachedTemplate.Name, 29, "Classic"
    lbl_Exit:
      Exit Sub
    End Sub
    Public Sub BBtoBM(BMName As String, BBName As String, _
                      Optional Template As String = "Normal", _
                      Optional GalleryIndex As Long = 9, _
                      Optional Category As String = "General")
    'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 9/18/2016
    'To use BuildingBlocks from a Gallery other than "AutoText" pass the appropriate
    'number as the Gallery argument.
    '1 Quick Parts|2 Cover Pages|3 Equations|4 Footers|5 Headers|6 Page Numbers|7 Tables
    '8 Watermarks|9 AutoText|10 Text Boxes|11 Page Numbers (Top of Page)|12 Page Numbers (Bottom of Page)
    '13 Page Numbers (Margins)|14 Table of Contents|15 Custom Quick Parts|16 Custom Cover Pages
    '17 Custom Equations|18 Custom Footers|19 Custom Headers|20 Custom Page Numbers|21 Custom Tables
    '22 Custom Watermarks|23 Custom AutoText|24 Custom Text Boxes|25 Custom Page Numbers (Top of Page)
    '26 Custom Page Numbers (Bottom of Page)|27 Custom Page Numbers (Margins)|28 Custom Tables
    '29 Custom 1|30 Custom 2|31 Custom 3|32 Custom 4|33 Custom 5|34 Bibliographies|'35 Custom Bibliographies
    Dim oTmpLoaded As Template, oTmp As Template
      Select Case Template
        Case "Normal"
          Set oTmp = Templates("Normal.dotm")
        Case ActiveDocument.AttachedTemplate.Name
           Set oTmp = ActiveDocument.AttachedTemplate 'Templates(Template)
        Case Else
          If Template = "Built-in Building Blocks" Then Templates.LoadBuildingBlocks
          For Each oTmpLoaded In Templates
            If UCase(CreateObject("scripting.filesystemobject").GetBaseName(oTmpLoaded.Name)) = UCase(Template) Then
              Set oTmp = oTmpLoaded
              Exit For
            End If
          Next
      End Select
      If Not oTmp Is Nothing Then
        If ActiveDocument.Bookmarks.Exists(BMName) Then
          On Error Resume Next
          ActiveDocument.Bookmarks.Add Name:=BMName, _
              Range:=oTmp.BuildingBlockTypes(GalleryIndex).Categories(Category).BuildingBlocks(BBName).Insert _
              (Where:=ActiveDocument.Bookmarks(BMName).Range, RichText:=True)
          If Not Err.number = 0 Then
            MsgBox "The defined buildingblock is not available.", vbInformation + vbOKOnly, "BUILDINGBLOCK NOT FOUND"
          End If
        Else
          MsgBox "The defined bookmark is not found in the document.", vbInformation + vbOKOnly, "BOOKMARK NOT FOUND"
        End If
      Else
        MsgBox "The building block template is not available.", vbInformation + vbOKOnly, "TEMPLATE NOT LOADED"
      End If
      
    lbl_Exit:
      Set oTmpLoaded = Nothing: Set oTmp = Nothing
      Exit Sub
    End Sub
    Public Sub BBtoCC(CCTitle As String, BBName As String, _
                      Optional Template As String = "Normal", _
                      Optional GalleryIndex As Long = 9, _
                      Optional Category As String = "General")
    'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 9/18/2016
    
    'To use BuildingBlocks from a Gallery other than "AutoText" pass the appropriate
    'number as the Gallery argument.
    '1 Quick Parts|2 Cover Pages|3 Equations|4 Footers|5 Headers|6 Page Numbers|7 Tables
    '8 Watermarks|9 AutoText|10 Text Boxes|11 Page Numbers (Top of Page)|12 Page Numbers (Bottom of Page)
    '13 Page Numbers (Margins)|14 Table of Contents|15 Custom Quick Parts|16 Custom Cover Pages
    '17 Custom Equations|18 Custom Footers|19 Custom Headers|20 Custom Page Numbers|21 Custom Tables
    '22 Custom Watermarks|23 Custom AutoText|24 Custom Text Boxes|25 Custom Page Numbers (Top of Page)
    '26 Custom Page Numbers (Bottom of Page)|27 Custom Page Numbers (Margins)|28 Custom Tables
    '29 Custom 1|30 Custom 2|31 Custom 3|32 Custom 4|33 Custom 5|34 Bibliographies|'35 Custom Bibliographies
    Dim oTmpLoaded As Template, oTmp As Template
    Dim oCC As ContentControl
      Select Case Template
        Case "Normal"
          Set oTmp = Templates("Normal.dotm")
        Case ActiveDocument.AttachedTemplate.Name
           Set oTmp = ActiveDocument.AttachedTemplate
        Case Else
          If Template = "Built-in Building Blocks" Then Templates.LoadBuildingBlocks
          For Each oTmpLoaded In Templates
            If UCase(CreateObject("scripting.filesystemobject").GetBaseName(oTmpLoaded.Name)) = UCase(Template) Then
              Set oTmp = oTmpLoaded
              Exit For
            End If
          Next
      End Select
      If Not oTmp Is Nothing Then
        On Error Resume Next
        Set oCC = ActiveDocument.SelectContentControlsByTitle(CCTitle).Item(1)
        If Not oCC.Type = wdContentControlRichText Then oCC.Type = wdContentControlRichText
        If Not oCC Is Nothing Then
          oTmp.BuildingBlockTypes(GalleryIndex).Categories(Category).BuildingBlocks(BBName).Insert oCC.Range, True
          If Not Err.number = 0 Then
            MsgBox "The defined buildingblock is not available.", vbInformation + vbOKOnly, "BUILDINGBLOCK NOT FOUND"
          End If
        Else
          MsgBox "The defined content control is not found in the document.", vbInformation + vbOKOnly, "BOOKMARK NOT FOUND"
        End If
      Else
        MsgBox "The building block template is not available.", vbInformation + vbOKOnly, "TEMPLATE NOT LOADED"
      End If
      
    lbl_Exit:
      Set oTmpLoaded = Nothing: Set oTmp = Nothing: Set oCC = Nothing
      Exit Sub
    End Sub
    Last edited by gmaxey; 12-18-2017 at 02:19 AM.
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    I would agree in principle, but as the autotexts are called directly from the document template, I would have thought that it was less likely that there would be duplicated names in that template.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  6. #6
    This works ace, now. Thanks!

    P.

  7. #7
    The second part is still a bit iffy. If I choose Lessons Observation, the table comes in at the right place. The Compilation of Comments building Blocks, though, do not get inserted. The seems to an incompatibility between the case and the if clauses.

  8. #8
    Works great! Thanks. BTW, is there and incompatibility of use between case and if statements? Can they be combined?

  9. #9
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    What do you mean? Give and example of what you want to do.
    Greg

    Visit my website: http://gregmaxey.com

  10. #10
    Quote Originally Posted by gmaxey View Post
    What do you mean? Give and example of what you want to do.
    <br>
    <br>
    Well, when "Compilation of Comments" is chosen from the ComboBoxDocType, then the Compilation of Comments frame pops up, giving the opportunity for the drafter to chose either General Comments, Specific Comments, or both. The General Comments item refers to the GeneralComments building Block in the Template and the Specific Comments to the SpecificComments Building Block. Those then would have to be entered at the EVTBookMark01 and the EVTBookMark02, respectively.<br>
    If the "Lessons Observation" document type is chosen from the drop-down list, then there is only one Building block associated to it, namely Table, which will then go to EVTBookMark01 in the document produced.<br>
    <br>
    This process is then repeated for the subsequent types of documents for which I am in the process of preparing the script along your lines. I have tested it out and only the CASE statement NOT combined with IF statements actually works:<br>
    <br>

    I am not sure I am making myself quite clear. I am sorry for that.<br>
    <br>
    Paskie_be<br>
    <br>

  11. #11
    The comprehensive coding is:
    Sub InsertExistingBuildingBlock()
    Select Case ComboBoxDocType.ListIndex
    Case Is = 0 'First item in list
    If ListBoxCoC.Text = "General Comments" Then
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "GeneralComments"
    End If
    If ListBoxCoC.Text = "Specific Comments" Then
    AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "SpecificComments"
    End If
    Case Is = 1 'Second item in list
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "Table"
    Case Is = 2
    If ListBoxMA.Text = "References" Then
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "References"
    End If
    If ListBoxMA.Text = "INTRODUCTION AND AIM" Then
    AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "INTRODUCTION"
    End If
    If ListBoxMA.Text = "CONSIDERATIONS" Then
    AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "CONSIDERATIONS"
    End If
    If ListBoxMA.Text = "RECOMMENDATION(S)" Then
    AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "RECOMMENDATIONS"
    End If
    Case Is = 3
    If ListBoxIMD.Text = "References" Then
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "References"
    End If
    If ListBoxIMD.Text = "SITUATION" Then
    AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "SITUATION"
    End If
    If ListBoxIMD.Text = "MISSION" Then
    AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "MISSION"
    End If
    If ListBoxIMD.Text = "DIRECTION" Then
    AutoTextToBM "EVTBookMark04", ActiveDocument.AttachedTemplate, "DIRECTION"
    End If
    If ListBoxIMD.Text = "ANNEXES" Then
    AutoTextToBM "EVTBookMark05", ActiveDocument.AttachedTemplate, "Annexes"
    End If
    Case Else 'Nothing selected
    End Select
    End Sub

  12. #12
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    You are not making yourself clear. Yes, Select Case and If statements can be used together:

    Sub Demo()
    Dim lngIndex As Long, lngTest1 As Long, lngTest2 As Long
      lngTest1 = 1
      For lngIndex = 1 To 3
        lngTest2 = lngIndex
        Select Case lngTest1
          Case 1
            If lngTest2 = 3 Then
              MsgBox "Viola"
            Else
              MsgBox lngTest2 & " isn't = to 3"
            End If
          Case 2
        
          Case 3
        End Select
      Next
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  13. #13
    OK.
    When a user opens the template as a new document, this screen pops up inviting him/her to choose a document type. The choice is between Compilation of Comments, Lessons Observation, Military Advice and Initiating Military Directive (IMD). According to the the document picked, a second frame opens in the same interface inviting the user to choose which parts of a document (=the building blocks) he wishes to see in his final document. For the Compilation of Comments, there are two options - General Comments and Specific Comments; for the Lessons Observation, there is only on (Table); for the Military Advice, there is References, INTRODUCTION AND AIM, CONSIDERATIONS and RECOMMENDATIONS; and for the IMD, we have References, SITUATION, MISSION, DIRECTION and ANNEXES.
    Depending on the number of building blocks, each one finds its place in the document at a specific bookmarks named EVTBookMark01 to 08.
    So, if the Compilation of Comments os the document to be produced and it is to contain a paragraph called General Comments and another called Specific Comments, the former goes to bookmark EVTBookMark01 in the document and the latter to bookmark EVTBookMark02.
    The same goes for the other document, mutatis mutandis.

  14. #14
    The trouble is I cannot attach my document to this thread. It might've made things easier to explain.

  15. #15
    Could it be that the Private Sub only allow for one building block to be inserted at one bookmark and not all selected blocks to find their place at the relevant bookmarks?

  16. #16
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    What Private Sub? The code graham and I have provided inserts 1 defined building block at 1 defined bookmark. If you wanted to insert BB A at bookmark A and BB B at bookmark B then you would have to call the sub twice.
    Greg

    Visit my website: http://gregmaxey.com

  17. #17
    Quote Originally Posted by gmaxey View Post
    What Private Sub? The code graham and I have provided inserts 1 defined building block at 1 defined bookmark. If you wanted to insert BB A at bookmark A and BB B at bookmark B then you would have to call the sub twice.
    Thanks.

    But, as you can see, I am only a starter. How can I do that?

  18. #18
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    You just call it one after the other.
    Select Case
    Case Some Case
    If Some Conditoion
    AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "SITUATION"
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "References"
    AutoTextToBM "EVTBookMark03", ActiveDocument.AttachedTemplate, "MISSION"
    End If
    End Select
    Greg

    Visit my website: http://gregmaxey.com

  19. #19
    Thank you very much indeed. I'll try tomorrow because it this time of the day when we knock off work on this side of the pond. Your help is very much appreciated! I'll let you know tomorrow what I could get out of it.

  20. #20
    I've got this:
    Select Case ComboBoxDocType.ListIndex
    Case Is = 0 'First item in list
    If ListBoxCoC.Text = "General Comments" Then
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "GeneralComments"
    End If
    If ListBoxCoC.Text = "Specific Comments" Then
    AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "SpecificComments"
    End If
    Case Is = 1 'Second item in list
    AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "Table"
    Case Else 'Nothing selected
    End Select

    And this is where the system blocks: under each case, I do not have multiple instructions but I have multiple Ifs inducing instructions.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •