VBA Bulk Import pictures to multiple Word documents and add titles (Flying fish)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.