You are on page 1of 1

' 엑셀 파일 열기

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

Dim excelWorkbook
Set excelWorkbook = excelApp.Workbooks.Open("C:\Users\FAS SCV01\Desktop\test.xlsx",
False)

' 폴더 경로 지정
Dim folderPath
folderPath = "C:\Users\FAS SCV01\Desktop\test\"

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

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

Dim imageFiles
Set imageFiles = folder.Files

Dim imagePath
imagePath ="C:\Users\FAS SCV01\Desktop\test\test.png"

' 삽입할 이미지 파일 이름

' 엑셀에 이미지 삽입


Dim excelSheet
Set excelSheet = excelWorkbook.ActiveSheet

Dim excelRange
Set excelRange = excelSheet.Range("A1")

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

' 엑셀 파일 저장 및 닫기
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