Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

' 엑셀 파일 열기

Dim excelApp
Set excelApp = CreateObject(Excel.Application)
excelApp.Visible = True

Dim excelWorkbook
Set excelWorkbook = excelApp.Workbooks.Open(CUsersFAS SCV01Desktoptest.xlsx, False)

' 폴더 경로 지정
Dim folderPath
folderPath = CUsersFAS SCV01Desktoptest

' FileSystemObject 생성
Dim fso
Set fso = CreateObject(Scripting.FileSystemObject)

' 폴더 내 모든 이미지 파일 처리
Dim folder
Set folder = fso.GetFolder(folderPath)

Dim imageFiles
Set imageFiles = folder.Files

Dim num
num = 1 ' 이미지가 들어갈 처음 cell 의 row 값
For each imageFile In imageFiles

' Output file properties to a text file

' 삽입할 이미지 파일 경로


Dim imagePath
imagePath = imageFile.Path

' 삽입할 이미지 파일 이름


Dim imageName
imageName = fso.GetFileName(imageFile.Path)

' 엑셀에 이미지 삽입


Dim excelSheet
Set excelSheet = excelWorkbook.ActiveSheet

Dim excelRange
Set excelRange = excelSheet.Range(B+CSTR(num)) '이미지 column 값이 B 라고 가정

Dim excelShape
Set excelShape = excelSheet.Shapes.AddPicture(imagePath, False, True,
excelRange.Left, excelRange.Top,-1 ,45)
excelShape.Name = imageName

Wscript.echo imageFile.path
num = num+1
Next

' 엑셀 파일 저장 및 닫기
excelWorkbook.Save
excelWorkbook.Close
' 객체 해제
Set excelShape = Nothing
Set excelRange = Nothing
Set excelSheet = Nothing
Set excelWorkbook = Nothing
excelApp.Quit
Set excelApp = Nothing
Set fso = Nothing

You might also like