VBA 프로그램을 개발 하려면 "참조 > Power Point OBJECT Library"를 추가 해야 합니다.
■ 엑셀에서 특정 경로에 있는 PPT 파일 열기
Sub PowerPointOpen()
Dim PowerPointApp As PowerPoint.Application
Dim oPresentation As PowerPoint.Presentation
Set PowerPointApp = CreateObject("PowerPoint.Application")
Set oPresentation = PowerPointApp.Presentations.Open("C:\IDT\TOOLBOX-VBA\POWERPOINT_TEMPLATE\PART_LIST.pptx")
End Sub
위 코드를 실행 하면 ToolBOX VBA 폴더에 있는 "PART_LIST.pptx" 파일을 Open 합니다.
■ 엑셀에서 특정 경로에 있는 PPT파일을 열고, 다른 이름으로 특정 폴더에 저장 하기
Sub PowerPointSaveAs()
Dim PowerPointApp As PowerPoint.Application
Dim oPresentation As PowerPoint.Presentation
Set PowerPointApp = CreateObject("PowerPoint.Application")
Set oPresentation = PowerPointApp.Presentations.Open("C:\IDT\TOOLBOX-VBA\POWERPOINT_TEMPLATE\PART_LIST.pptx")
oPowerPointPathName = "c:\idt\korea.pptx"
oPresentation.SaveAs (oPowerPointPathName)
oPresentation.Close
PowerPointApp.Quit
Set PowerPointApp = Nothing
Set oPresentation = Nothing
End Sub
shapes 개체는 매우 많은 유형이 있습니다. 글상자도 있고, 화살표도 있고, 차트도 있고 표 (Table)도 있습니다.
shapes 1개 | shapes 3개 |
![]() |
![]() |
■ Table의 cell에 "OK" 입력 하기
Sub PowerPointText()
Dim PowerPointApp As PowerPoint.Application
Dim oPresentation As PowerPoint.Presentation
Set PowerPointApp = CreateObject("PowerPoint.Application")
Dim oSlide As PowerPoint.Slide
Dim oSlideCount, i As Long
oSlideCount = PowerPointApp.ActivePresentation.Slides.Count
For i = 1 To oSlideCount
PowerPointApp.ActivePresentation.Slides(i).Shapes(1).Table.Cell(2, 1).Shape.TextFrame.TextRange.Text = "ok"
Next i
End Sub
■ table cell에 이미지 삽입 하기
PowerPoint.ActivePresentation.Slides(1).Shapes("table_1").Table.Cell(1, 2).Shape.Fill.UserPicture ("location_of_picture_file")
■ TABLE 이름 변경 방법
How to rename objects in PowerPoint – Sharon's Tutorials
I use cookies on my website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlle
sharonstutorials.com
■ chatgpt
엑셀 VBA에서 파워포인트 표에 그림을 넣는 예시 코드입니다
Sub InsertPictureToPowerPointTable()
' Powerpoint 객체 생성
Dim pptApp As Object
Dim pptPres As Object
Dim pptSlide As Object
Dim pptTable As Object
' 이미지를 삽입할 행과 열 지정
Dim rowIndex As Long
Dim colIndex As Long
' 이미지 파일 경로 지정
Dim pictureFilePath As String
' Powerpoint 객체 생성
Set pptApp = CreateObject("Powerpoint.Application")
Set pptPres = pptApp.Presentations.Open("C:\example.pptx")
Set pptSlide = pptPres.Slides(1)
Set pptTable = pptSlide.Shapes("Table 1").Table ' "Table 1" 대신 테이블의 이름을 입력해주세요.
' 이미지를 삽입할 행과 열 지정
rowIndex = 2 ' 2번째 행에 삽입
colIndex = 3 ' 3번째 열에 삽입
' 이미지 파일 경로 지정
pictureFilePath = "C:\example.jpg"
' 이미지를 표에 삽입
With pptTable.Cell(rowIndex, colIndex).Shape
.LockAspectRatio = msoTrue
.Width = pptTable.Cell(rowIndex, colIndex).Shape.Parent.Parent.Columns(colIndex).Width - 2
.Height = pptTable.Cell(rowIndex, colIndex).Shape.Parent.Parent.Rows(rowIndex).Height - 2
.Fill.UserPicture (pictureFilePath)
End With
' Powerpoint 객체 종료
pptPres.Save
pptPres.Close
pptApp.Quit
Set pptTable = Nothing
Set pptSlide = Nothing
Set pptPres = Nothing
Set pptApp = Nothing
End Sub
이 코드에서는 먼저 Powerpoint 객체를 생성하고, 이미지를 삽입할 행과 열의 인덱스를 지정하고, 이미지 파일의 경로를 지정합니다. 그 후, pptTable.Cell(rowIndex, colIndex).Shape을 사용하여 해당 위치의 셀에 이미지를 삽입하게 됩니다. 이미지 삽입 후에는 Powerpoint 객체를 종료하는 부분이 있습니다.
주의해야 할 점은 해당 코드를 실행하기 위해서는 Microsoft Powerpoint가 설치되어 있어야 한다는 것입니다. 또한, pictureFilePath 변수에는 삽입하고자 하는 이미지 파일의 절대 경로를 입력해야 합니다.
엑셀의 cell안에 이미지 삽입 하기
엑셀 VBA 이미지 셀 크기에 자동으로 삽입하는 매크로 만들기
사진을 셀에 맞추기 위해서는 몇 가지 작업을 해야 합니다. 그림서식으로 가서 속성을 변경하고 이미지를 셀 크기만큼 조절해서 맞춥니다. 복잡하지 않지만 좀더 간단하게 할 수 있는 방법이 없
mainia.tistory.com
엑셀 매크로 셀 크기에 맞게 그림 이미지 불러 오기
엑셀 매크로 셀 크기에 맞게 그림 이미지 불러오기 엑셀 작업 시 폼을 그리고 폼에 따라 이미지를 삽입해서 작업을 하기도 합니다. 이 폼에 따라 불러온 이미지는 보통 셀 크기에 맞게 이미지를
loveuceci.tistory.com
엑셀의 데이터를 ppt 파일로 보내기
'VBA VB.Net Code' 카테고리의 다른 글
배열을 사용하여 Drop Down List 만들기 (0) | 2022.12.05 |
---|---|
CELL 사이즈 조정 하는 코드 (0) | 2022.11.09 |
체크 박스 만들고 ,삭제 하기 / 전체 선택, 전체 해제 #3 (0) | 2022.11.02 |
체크 박스 만들고 ,삭제 하기 / 전체 선택, 전체 해제 #2 (0) | 2022.11.02 |
IIf Intersect([A2:C2], [B:B]) Is Nothing Then (0) | 2022.11.02 |