Batch import pictures to Word and add file names

Source: Internet
Author: User

Sub insertpic () Dim myfile as FileDialog Set myfile = Application.filedialog (msofiledialogfilepicker) with myfile .        InitialFileName = "F:\" If. Show =-1 Then for each of the FN in.                SelectedItems Set mypic = Selection.InlineShapes.AddPicture (FILENAME:=FN, Savewithdocument:=true) ' Proportionally adjust the photo size Widthnum = mypic. Width c = 10 ' Change the photo width here, unit cm mypic. Width = c * 28.35 mypic. Height = (c * 28.35/widthnum) * mypic. Height if Selection.start = Activedocument.content.end-1 Then ' If the cursor is at the end of the text Selection.typep Aragraph ' Add an empty segment at the end of the article Else Selection.movedown end If Selec tion. Text = Basename (fn) ' function gets the file name Selection.endkey If Selection.start = activedocument.content . End-1 then ' as the cursor at the end of the Selection.typeparagraph ' at the end of the text add an empty paragraph Else                   Selection.movedown End If Next fn Else End if End with Se  T myfile = NothingEnd subfunction Basename (FullPath) ' Get file name Dim x, y Dim tmpstring tmpstring = FullPath x =            Len (FullPath) for y = x to 1 Step-1 If Mid (FullPath, y, 1) = "\" or _ Mid (FullPath, y, 1) = ":" Or _    Mid (FullPath, y, 1) = "/" Then tmpstring = Mid (FullPath, y + 1) Exit for End If Next Basename = Left (tmpstring, Len (tmpstring)-4) End Function

Batch import pictures to Word and add file names

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.