Forum Discussion
Kevin_McElvaney
Oct 09, 2023Copper Contributor
Repetitive form filling
hello asking if there is a solution. Daily I have to update 9 to 11 work permits. The list of permits Title, date and number are in an Excel spreadsheet. The permits are Word docs, stored in a folder ...
Kevin_McElvaney If you post back with the code of the macro, we should be able to tell you how to modify it (probably by the use of some InputBox commands) so that you will be asked for the information from the document interface, rather than having to modify the macro.
Kevin_McElvaney
Oct 10, 2023Copper Contributor
Thank you for the prompt reply, below is the Macro
Sub Macro1()
'
' Macro1 Macro
' permit change
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "GP1310"
.Replacement.Text = "GP1319"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "09-10-23"
.Replacement.Text = "10-10-23"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ChangeFileOpenDirectory _
"C:\Users\Kevin.McElvaney\Desktop\Permits\10 Oct\10.10.23\"
ActiveDocument.SaveAs2 FileName:= _
"Boilers - General activities Scaffold (erection)GP1319.docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveWindow.Close
Application.Quit
End Sub
Sub Macro1()
'
' Macro1 Macro
' permit change
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "GP1310"
.Replacement.Text = "GP1319"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "09-10-23"
.Replacement.Text = "10-10-23"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ChangeFileOpenDirectory _
"C:\Users\Kevin.McElvaney\Desktop\Permits\10 Oct\10.10.23\"
ActiveDocument.SaveAs2 FileName:= _
"Boilers - General activities Scaffold (erection)GP1319.docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveWindow.Close
Application.Quit
End Sub
- Oct 11, 2023
Kevin_McElvaney Can you also upload a copy of the document as that will allow me to create the best solution for you,