회사에서 파워포인트 문서 nn개를 한장 한장 분리하라고... 시켜서... 어떻게든 편한 방법을 찾아냄
Sub 페이지분할()
Dim oPresentation As Presentation
Dim oNewPresentation As Presentation
Dim slideIndex As Integer
Dim folderPath As String
Dim slideName As String
Dim presentationName As String
Dim basePath As String
Dim totalSlides As Integer
Dim i As Integer
' 현재 프레젠테이션을 변수에 할당
Set oPresentation = ActivePresentation
' 현재 프레젠테이션의 파일명 가져오기 (확장자 제거)
presentationName = Left(oPresentation.Name, InStrRev(oPresentation.Name, ".") - 1)
' basePath 경로 수정 (E:\temps)
basePath = "E:\temps"
' 파일 이름을 포함한 저장 폴더 경로 (E:\temps\PresentationName)
folderPath = basePath & "\" & presentationName
' 폴더가 존재하지 않을 경우 폴더 생성
If Dir(folderPath, vbDirectory) = "" Then
MkDir folderPath
End If
' 슬라이드 개수 가져오기
totalSlides = oPresentation.Slides.Count
' 슬라이드 개수만큼 반복
For slideIndex = 1 To totalSlides
' 현재 프레젠테이션을 복제하여 새 프레젠테이션 생성
oPresentation.SaveCopyAs folderPath & "\" & "TempPresentation.pptx"
Set oNewPresentation = Presentations.Open(folderPath & "\" & "TempPresentation.pptx")
' 슬라이드 방향 복사 (가로/세로)
oNewPresentation.PageSetup.SlideOrientation = oPresentation.PageSetup.SlideOrientation
' 모든 슬라이드를 삭제하고 slideIndex 슬라이드만 남기기
For i = oNewPresentation.Slides.Count To 1 Step -1
If i <> slideIndex Then
oNewPresentation.Slides(i).Delete
End If
Next i
' 슬라이드 이름 지정 (예: "Slide_1.pptx")
slideName = "Slide_" & slideIndex & ".pptx"
' 새 프레젠테이션을 지정된 폴더에 저장
oNewPresentation.SaveAs folderPath & "\" & slideName
' 새 프레젠테이션 닫기
oNewPresentation.Close
Next slideIndex
' 임시 프레젠테이션 파일 삭제
Kill folderPath & "\" & "TempPresentation.pptx"
' 완료 메시지
MsgBox "All slides have been saved as separate PPT files in " & folderPath
End Sub
'개발공부 > 혼자놀기' 카테고리의 다른 글
네이버 클라우드 서버 꾸미기 - 데이터베이스 설치하기 (0) | 2022.04.15 |
---|---|
네이버 클라우드 서버 꾸미기 - 패키지 관리도구 설치 (0) | 2022.04.15 |
네이버 클라우드 서버에 문고리 달기 (0) | 2022.04.15 |
네이버 클라우드 서버님 문 좀 열어주세요 (0) | 2022.04.15 |
장소 대관 시스템 테이블 구조도 (0) | 2022.02.09 |
댓글