Dbai100
08-21-2023, 12:17 PM
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
.Execute
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
.ClearFormatting
.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 .....https://www.listendata.com/2020/12/vba-copy-text-one-word-document-to-another.html
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!
:crying:
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
.Execute
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
.ClearFormatting
.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 .....https://www.listendata.com/2020/12/vba-copy-text-one-word-document-to-another.html
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!
:crying: