Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Aug 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A Userform that populates Quick Parts?

    Hello, I am new here and from what I have read this looks like the best place to ask my question!

    I have created a document template with multplie quick parts. The quick parts details all aspects of a given subject and at the moment I am going to ALT > N > Q and just scrolling down the quick parts and selecting the ones I want which is great but I was thinking is there a faster way to do this?

    What I really want is to have a picking list at the start of the document with all the quick part titles listed with a check box. If one of the boxes is checked the whole quick part is displayed at a certain point in the document.

    Does anyone know if this is even possible? To create a tick box that will populate a quick part once checked?

    Thanks in advance for anyone that might have any ideas!!

  2. #2
    Star Lounger Graham Mayor's Avatar
    Join Date
    Mar 2016
    Location
    Cyprus
    Posts
    69
    Thanks
    0
    Thanked 24 Times in 24 Posts
    There is no doubt that it would be possible to create a userform with a multi select listbox containing the descriptions, the names of the building blocks and the bookmark names they pertain to in three columns (the second and third set to zero width so, in effect, hidden)

    You can then call the following macro for each selected item to write that item to the appropriate bookmark in the document

    Code:
    Sub InsertItem(strBuildingBlock As String, strBMName As String)
    Dim oRng As Range, oEnd As Range
        With ActiveDocument
            On Error GoTo lbl_Exit
            Set oRng = .Bookmarks(strBMName).Range
            oRng.Text = ""
            Set oEnd = oRng.Next
            oEnd.Collapse 1
            Application.Templates(ThisDocument.FullName). _
                    BuildingBlockEntries(strBuildingBlock).Insert _
                    Where:=oRng, _
                    RichText:=True
            oRng.End = oEnd.start - 1
            oRng.Bookmarks.Add strBMName
        End With
    lbl_Exit:
        Set oRng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - Word MVP
    http://www.gmayor.com

  3. The Following User Says Thank You to Graham Mayor For This Useful Post:

    Charles Kenyon (2016-08-19)

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
  •