跳到主要內容

 如何在Word文檔中插入相同大小的多張圖片?

通常,您可以一次在Word文檔中插入原始大小的多個圖像。 有時,插入時需要將這些圖像排列為相同大小。 本文,我將討論如何在Word文檔中插入相同大小的多張圖片。

使用VBA代碼在Word文檔中插入相同大小的多張圖片

使用Kutools for Word根據特定圖像將所有圖片調整為相同大小


使用VBA代碼在Word文檔中插入相同大小的多張圖片

以下vba代碼可以幫助您插入多張圖片,並立即將它們調整為指定的大小,請按以下步驟操作:

1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

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  /  將頁面匯出為圖像  /  一次列印多個文件...

內容編輯: 批量查找和替換 跨多個文件  /  調整所有圖片的大小  /  轉置表行和列  /  將表格轉換為文字...

🧹 輕鬆清潔: 移開 多餘的空間  /  分節符  /  所有標題  /  文本框  /  超鏈接  / 如需更多拆卸工具,請前往我們的 刪除組...

創意插入: 插入 千位分隔符  /  複選框  /  單選按鈕  /  QR Code  /  條碼  /  對角線表  /  公式標題  /  圖片說明  /  表格標題  /  多張圖片  / 發現更多 插入組...

🔍 精準選擇:精確定位 特定頁面  /    /  形狀  /  標題段落  / 增強導航功能 更多 選擇功能...

星級增強: 快速導航至任何位置  /  自動插入重複文字  /  在文檔視窗之間無縫切換  /  11 轉換工具...

???? 想嘗試這些功能嗎? Kutools for Word 提供了 60天免費試用,沒有任何限制! 🚀
 
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