跳到主要内容

 如何在Word文档中插入相同大小的多张图片?

通常,您可以一次在Word文档中插入原始大小的多个图像。 有时,插入时需要将这些图像排列为相同大小。 本文,我将讨论如何在Word文档中插入相同大小的多张图片。

使用VBA代码在Word文档中插入相同大小的多张图片

使用 Kutools for Word 根据特定图像将所有图片调整为相同大小


使用VBA代码在Word文档中插入相同大小的多张图片

以下vba代码可以帮助您插入多张图片,并立即将它们调整为指定的大小,请按以下步骤操作:

1。 按住 ALT + F11 键打开 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将以下代码粘贴到“模块窗口”中。

VBA代码:插入多张相同大小的图片:

Sub InsertSpecificNumberOfPictureForEachPage()
    Dim xDlg As FileDialog
    Dim xFilePath As String
    Dim xFileName As String
    Dim xMsbBoxRtn As Long
    Dim xPicSize As String
    Dim xShape As InlineShape
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show = -1 Then
        xFilePath = xDlg.SelectedItems(1) & "\"
    Else
        Exit Sub
    End If
    xFileName = Dir(xFilePath & "*.*", vbNormal)
    While xFileName <> ""
        If Not (Right(xFileName, 4) = ".png" Or Right(xFileName, 4) = ".bmp" _
        Or Right(xFileName, 4) = ".jpg" Or Right(xFileName, 4) = ".ico") Then
            GoTo LblCtn
        End If
        With Selection
            .InlineShapes.AddPicture xFilePath & xFileName, False, True
            .TypeParagraph
            .Collapse wdCollapsEnd
            .TypeText Left(xFileName, InStrRev(xFileName, ".") - 1)
            .ParagraphFormat.Alignment = wdAlignParagraphCenter
            .TypeParagraph
        End With
LblCtn:
        xFileName = Dir()
    Wend
    ActiveDocument.InlineShapes(1).Select
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    xMsbBoxRtn = MsgBox("Do you want to resize all pictures?", vbYesNo, "Kutools for Word")
    If xMsbBoxRtn = 6 Then
        xPicSize = InputBox("Input the height and width of the picture, separated by comma", "Kutools for Word", "")
    End If
    For Each xShape In ActiveDocument.InlineShapes
      xShape.Height = Split(xPicSize, ",")(0)
      xShape.Width = Split(xPicSize, ",")(1)
    Next xShape
End Sub

3。 然后,按 F5 运行此代码的关键 浏览 显示窗口,请选择包含要插入图像的文件夹,请参见屏幕截图:

doc插入大小相同的图片1

4。 然后点击 OK 按钮,并弹出提示框,提醒您是否要调整图片大小,请参见屏幕截图:

doc插入大小相同的图片2

5。 点击 ,然后在文本框中输入用逗号分隔的高度和宽度的尺寸编号,请参见屏幕截图:

doc插入大小相同的图片3

6。 然后点击 OK,所有插入的图像均已重新排列为相同大小,请参见屏幕截图:

doc插入大小相同的图片4

备注:单位大小在VBA代码中为“池塘”。


使用 Kutools for Word 根据特定图像将所有图片调整为相同大小

如果您的Word文档中存在多张图片,请使用 Kutools for Word调整图像大小 实用程序,您可以快速调整所有图像的大小,使其与特定图像相同。

Kutools for Word : 带有超过100个方便的Word加载项,可以在60天内免费试用. 

安装后 Kutools for Word,请这样做:

1。 将一张图片调整为所需的尺寸,然后选择它,然后单击 Kutools 加 > 调整大小 > 通过选择调整图像大小,请参见屏幕截图:

2。 并且此Word文档中的所有图像都立即被调整为与所选图像相同的大小,请参见屏幕截图:

点击下载Kutools for Word并立即免费试用!

最佳办公生产力工具

Kutools for Word - 通过 Over 提升您的文字体验 100 显着特点!

🤖 Kutools 人工智能助手:用人工智能改变你的写作 - 生成内容  /  重写文本  /  总结文件  /  查询资料 基于文档,全部在Word中

📘 文档掌握: 分页  /  合并文件  /  以各种格式导出选择(PDF/TXT/DOC/HTML...)  /  批量转换为PDF  /  将页面导出为图像  /  一次打印多个文件...

内容编辑: 批量查找和替换 跨多个文件  /  调整所有图片的大小  /  转置表行和列  /  将表格转换为文字...

🧹 轻松清洁: 移开 多余的空间  /  分节符  /  所有标题  /  文本框  /  超链接  / 如需更多拆卸工具,请前往我们的 删除组...

创意插入: 插 千位分隔符  /  复选框  /  单选按钮  /  扫码支付  /  条码  /  对角线表  /  公式标题  /  图片说明  /  表标题  /  多张图片  / 发现更多 插入组...

🔍 精准选择:精确定位 特定页面  /    /  形状  /  标题段落  / 增强导航功能 更多 选择功能...

星级增强: 快速导航至任何位置  /  自动插入重复文本  /  在文档窗口之间无缝切换  /  11 转换工具...

👉 想尝试这些功能吗? Kutools for Word 提供了 60-day免费试用,没有任何限制! 🚀
 
Comments (4)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Molto bello e utile! Non mi è chiara solo un a cosa, nel Codice VBA con criterio aumento/diminuisco le dimensioni delle immagini? Percentuale/rapporto? pixel? cm?
GRAZIE!
This comment was minimized by the moderator on the site
Hello, Grasselli
The unit size is pond in the above VBA code.
Thank you!
This comment was minimized by the moderator on the site
thanks for help ... it is very interesting ... big job ... good luck
This comment was minimized by the moderator on the site
Hi, hello
I'm Soda, I'm here to say that, I really learn a lot with your website and information that you give.
Thanks for that :)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations