900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > word插入图片的同时自动插入图片名称

word插入图片的同时自动插入图片名称

时间:2021-04-16 08:37:12

相关推荐

word插入图片的同时自动插入图片名称

文章目录

1.打开一个需要插入的word2.打开Word VBA3.点击ThisDocument4.粘贴代码进去,然后关闭(复制代码,别手敲!!!)5.点击运行宏6.选择要插入的图片目录7.大功告成

1.打开一个需要插入的word

2.打开Word VBA

快捷键:Alt+F11

3.点击ThisDocument

4.粘贴代码进去,然后关闭(复制代码,别手敲!!!)

Sub PicWithCaption()Dim xFileDialog As FileDialogDim xPath, xFile As VariantDim indexindex = index + 1On Error Resume NextSet xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)If xFileDialog.Show = -1 ThenxPath = xFileDialog.SelectedItems.Item(1)If xPath <> "" ThenxFile = Dir(xPath & "\*.*")Do While xFile <> ""If UCase(Right(xFile, 3)) = "PNG" Or _UCase(Right(xFile, 3)) = "TIF" Or _UCase(Right(xFile, 3)) = "JPG" Or _UCase(Right(xFile, 3)) = "GIF" Or _UCase(Right(xFile, 3)) = "BMP" ThenWith Selection.InlineShapes.AddPicture xPath & "\" & xFile, False, True.InsertAfter vbCrLf.MoveDown wdLine.Text = "图" & index & "-" & xFile.MoveDown wdLine.MoveDown wdLineindex = index + 1End WithEnd IfxFile = Dir()LoopEnd IfEnd IfEnd Sub

5.点击运行宏

快捷键:F5

6.选择要插入的图片目录

7.大功告成

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。