Thank you for the Flying fish Daniel ~
1 Publicfp$, Obmapp as Object2 SubKK ()3 folder Browser4Application.ScreenUpdating =False5 SetFSO =CreateObject("Scripting.FileSystemObject")6 IfFP ="" Then Exit Sub7 SetFF =Fso.getfolder (FP)8 forx =1 to -9Documents.Add documenttype:=wdnewblankdocumentTen for eachFdinchff.subfolders Onet =Int(FD. Files.count/ -) A fory =1 toT -Selection.InlineShapes.AddPicture FILENAME:=FD &"\"& x * t-t + y &". PNG", linktofile:=False, savewithdocument:=True - Selection.typeparagraph theSelection.TypeText TEXT:=FD. Name &"_"&Format(x * t-t + y,"xx") &Chr( -) - Next - Next - selection.wholestory +Selection.ParagraphFormat.Alignment =wdAlignParagraphCenter - + 'the + in the replacement name is/ A Selection.Find.ClearFormatting at Selection.Find.Replacement.ClearFormatting - withSelection.Find -. Text ="+" -. Replacement.text ="/" -. Forward =True -. Wrap =wdfindcontinue in. Format =False -. MatchCase =False to. MatchWholeWord =False +. MatchByte =True -. MatchWildcards =False the. MatchSoundsLike =False *. MatchAllWordForms =False $ End withPanax NotoginsengSelection.Find.ExecuteReplace:=wdReplaceAll - 'above is the recorded macro theACTIVEDOCUMENT.SAVEAS2 FILENAME:=FP &"\"& X &". docx" + Activewindow.close A Next theApplication.ScreenUpdating =True + End Sub - Subfolder browser () $ SetObmapp =CreateObject("shell.application"). BrowseForFolder (0,"Please select a file directory:",0,0) $ If notObmapp is Nothing Then -fp = Obmapp. Self.path &"" - Else the Exit Sub - End IfWuyi End Sub
VBA Bulk Import pictures to multiple Word documents and add titles (Flying fish)