메인 컨텐츠로 가기

Word 문서에 파일 이름으로 여러 그림을 삽입하는 방법은 무엇입니까?

Word 문서에서 삽입 기능을 사용하여 한 번에 여러 그림을 빠르게 삽입 할 수 있습니다. 그러나 때로는 그림을 삽입 할 때 파일 경로와 이름을 캡션으로 삽입해야합니다. Word 파일에서이 작업을 어떻게 처리 할 수 ​​있습니까?

VBA 코드를 사용하여 파일 이름으로 여러 그림 삽입

Word 용 Kutools를 사용하여 파일 이름으로 여러 그림 삽입


VBA 코드를 사용하여 파일 이름으로 여러 그림 삽입

다음 VBA 코드는 이미지를 삽입 할 때 파일 경로와 이름을 캡션으로 삽입하는 데 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 누르고 ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 그런 다음 끼워 넣다 > 모듈, 아래 코드를 복사하여 열린 빈 모듈에 붙여 넣습니다.

VBA 코드 : 파일 이름으로 여러 그림 삽입 :

Sub PicWithCaption()
    Dim xFileDialog As FileDialog
    Dim xPath, xFile As Variant
    On Error Resume Next
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    If xFileDialog.Show = -1 Then
        xPath = xFileDialog.SelectedItems.Item(1)
        If xPath <> "" Then
            xFile = 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" Then
                    With Selection
                        .InlineShapes.AddPicture xPath & "\" & xFile, False, True
                        .InsertAfter vbCrLf
                        .MoveDown wdLine
                        .Text = xPath & "\" & xFile & Chr(10)
                        .MoveDown wdLine
                    End With
                End If
                xFile = Dir()
            Loop
        End If
    End If
End Sub

3. 그런 다음 F5 키를 눌러이 코드를 실행하면 찾아보기 창이 표시됩니다. 삽입하려는 이미지가 포함 된 폴더를 선택하십시오. 스크린 샷을 참조하십시오.

파일 이름이 1 인 문서 삽입 이미지

4. 그런 다음 OK 버튼을 클릭하면 선택한 폴더의 모든 이미지가 Word 문서에 삽입되고 파일 경로와 이름이 캡션으로 삽입됩니다. 스크린 샷 참조 :

파일 이름이 2 인 문서 삽입 이미지


Word 용 Kutools를 사용하여 파일 이름으로 여러 그림 삽입

당신이 있으면 Word 용 Kutools그와 이미지 기능을 사용하면 파일 경로와 이름이있는 여러 그림을 Word 문서에 즉시 빠르게 삽입 할 수 있습니다.

Word 용 Kutools : 100 개 이상의 편리한 Word 추가 기능으로 60 일 동안 제한없이 무료로 사용해 볼 수 있습니다.. 

설치 후 Word 용 Kutools, 다음과 같이하십시오.

1. 쿠툴 > 이미지, 스크린 샷 참조 :

파일 이름이 3 인 문서 삽입 이미지

2. 튀어 나온 그림 삽입 대화 상자에서 아래 작업을 수행하십시오.

  • (1.) 클릭 파일 추가 or 폴더 추가 삽입 할 이미지를 선택하는 버튼;
  • (2.) 그런 다음 확인 각 그림의 파일 경로를 캡션으로 삽입 대화 상자의 왼쪽 하단에있는 옵션;
  • (3.) 그런 다음 끼워 넣다 버튼을 클릭합니다.

파일 이름이 4 인 문서 삽입 이미지

3. 이미지를 삽입하면 각 그림의 파일 경로와 이름도 삽입되는 것을 볼 수 있습니다. 스크린 샷을 참조하십시오.

파일 이름이 5 인 문서 삽입 이미지

지금 Word 및 무료 평가판 용 Kutools를 다운로드하려면 클릭하십시오!

최고의 사무 생산성 도구

Word 용 Kutools - Over로 단어 경험을 향상시키세요 100 놀라운 기능!

🤖 Kutools AI 도우미: AI로 글쓰기를 변화시키세요 - 콘텐츠 생성  /  텍스트 다시 쓰기  /  문서 요약  /  정보 문의 문서 기반, 모두 Word 내에서

📘 문서 숙달: 페이지 분할  /  문서 병합  /  다양한 형식으로 선택 항목 내보내기(PDF/TXT/DOC/HTML...)  /  PDF로 일괄 변환  /  페이지를 이미지로 내보내기  /  한 번에 여러 파일 인쇄...

컨텐츠 편집: 일괄 찾기 및 바꾸기 여러 파일에 걸쳐  /  모든 사진 크기 조정  /  테이블 행과 열 바꾸기  /  표를 텍스트로 변환...

🧹 손쉬운 청소: 쓸어버리다 추가 공간  /  섹션 나누기  /  모든 헤더  /  텍스트 상자  /  하이퍼 링크  / 더 많은 제거 도구를 보려면 다음 페이지를 방문하세요. 그룹 제거...

광고 삽입물: 삽입 천 단위 구분 기호  /  확인란  /  라디오 버튼  /  QR 코드  /  바코드  /  대각선 표  /  방정식 캡션  /  이미지 캡션  /  테이블 캡션  /  여러 장의 사진  / 더 자세히 알아보세요. 그룹 삽입...

🔍 정밀한 선택: 핀포인트 특정 페이지  /  테이블  /  모양  /  제목 단락  / 탐색 기능 향상 배우기 기능 선택...

스타 강화: 어떤 위치로든 빠르게 이동  /  반복되는 텍스트 자동 삽입  /  문서 창 간을 원활하게 전환합니다.  /  11 변환 도구...

👉 이러한 기능을 사용해 보고 싶으신가요? Word 용 Kutools는 다음을 제공합니다. 60 일 무료 사용, 제한 없음! 🚀
 
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
VBA CODE IS VERY USEFULLY MY DATA VALIDATE IMAGES SHARING.
This comment was minimized by the moderator on the site
How can I decrease the overall size of the photo so there are multiple per page?
This comment was minimized by the moderator on the site
Is there a way to insert each picture and file name per page? Sometimes if one picture is too big the file name will then go to the next page or if picture is too small the next picture will be together in one page instead on the next page
This comment was minimized by the moderator on the site
Hello, Rizza,
To insert each picture and file name per page, please apply the following vba code:
Sub PicWithCaption()
    Dim xFileDialog As FileDialog
    Dim xPath As String, xFile As String
    On Error Resume Next
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    If xFileDialog.Show = -1 Then
        xPath = xFileDialog.SelectedItems.Item(1)
        If xPath <> "" Then
            xFile = 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" Then
                    
                    ' Add the picture
                    Selection.InlineShapes.AddPicture xPath & "\" & xFile, False, True
                    Selection.TypeParagraph
                    
                    ' Add the file path below the picture
                    Selection.TypeText xPath & "\" & xFile
                    Selection.TypeParagraph
                    
                    ' Move to the next page
                    Selection.InsertBreak Type:=wdPageBreak
                End If
                xFile = Dir()
            Loop
        End If
    End If
End Sub


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
A problem occurs when the file name to be added exceeds 10.

pic1
pic10
pic11
pic12
pic2
pic3
pic4
pic5...
This comment was minimized by the moderator on the site
change the file name to 01, 02, 03 and it will work
This comment was minimized by the moderator on the site
Wow this is great! I only needed the file name, so I deleted "xPath & "\" &" from the .Text line and that worked perfectly. Thanks for this!
This comment was minimized by the moderator on the site
Which line of code would you change and how to have the file path written before the picture, aka the caption (filename) is above rather than below.
This comment was minimized by the moderator on the site
With Selection
.Text = xFile
.InlineShapes.AddPicture xPath & "\" & xFile, False, True
.InsertAfter vbCrLf
.MoveDown wdLine

End With
This comment was minimized by the moderator on the site
Have to add this .MoveDown wdLine after .Text=xFile
This comment was minimized by the moderator on the site
buenas noches amigo me ha servido mucho su información sinembargo me surge una duda cree que es posible incertar imagenes en word de la misma manera pero dentro de celdas incertadas?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations