Results 1 to 2 of 2

Thread: Code to migrate text in particular paragraps into an existing document

  1. #1
    VBAX Newbie
    Aug 2023

    Question Code to migrate text in particular paragraps into an existing document

    My goal is to automate a few things to make life easier and save hours of manual work (3-4 hours on each one!) but I am not a developer of any kind. I see lots of sample macros but get lost.Im hoping someone can help me out

    My nirvana would be

    1. Open a doc (doc1) based on template 1, and be prompted for "what is Q1" which populates that field throughout the doc and save it. I found this code;
    With ActiveDocument.Content.Find
    .Text = "blue"
    .Forward = True
    If .Found = True Then .Parent.Bold = True
    End With

    2. When closing the file be prompted to delete specific paragraphs "Are you ready to delete instruction paragraphs" I found this code:
    Sub DeleteStyleText()
    Application.ScreenUpdating = False
    Dim strStyles As String, i As Long
    strStyles = strStyles & "Style1,Style2,Style3,Style4,Style5,"
    strStyles = strStyles & "Style6,Style7,Style8,Style9,Style10,"
    strStyles = strStyles & "Style11,Style12,Style13,Style14,Style15"
    With ActiveDocument.Content.Find
    .Format = True
    .Text = ""
    .Replacement.Text = ""
    .Wrap = wdFindContinue
    For i = 0 To UBound(Split(strStyles, ","))
    .Style = Split(strStyles, ",")(i)
    .Execute Replace:=wdReplaceAll
    Next i
    End With
    Application.ScreenUpdating = True
    End Sub

    3. And Lastly take the paragraphs from Doc1 into Doc 2 .....

    And I confess Im stumped. How do I tie these together? How do I actually get these to work in a template so that every doc based off that template does this?

    I will be forever grateful if someone more versed in this than I am can help a newbie out!
    Thank you in advance!

  2. #2
    VBAX Contributor
    Jul 2020
    Sun Prairie
    Rather than vba, look into AutoText and Building Blocks.

    Look also at the Building Blocks Gallery Content Control, which can, itself, be set as a building block.

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