문제

내가 만들어 일부에서 코드 Excel VBA 을 만드는 PowerPoint 슬라이드 프레젠테이션 1 의 각 행에 대해 Excel,채 특정 텍스트 상자에서 파워포인트가 있습니다.
지금 추가하려는 모든 이미지와 일치하는 설명이 있습니다.이들은 모두 Jpeg 파일과하지 않 차트 등등.
이렇게 하려면 어떻게 해야 합니까,그것은 더 나은 엑셀에서,또는 그것이 나를 이렇게 Powerpoint VBA 까?
Eitherway,사람을 도울 수 밖으로 나와 일부 코드에서 어떻게 이렇게 하십시오?
이미지 프레임에 이미 존재하는 파워포인트가 있습니다.거기에는 2 개의 이미지를 당 슬라이드(아 전환 또는 아무것도).
감사합니다!

P.S I am 파워 포인트를 사용하고 Excel2010 년에 윈도우 7.


하는 방법이 있나요 이렇게 엑셀에서?의 나머지 부분은 내 코드는 Excel 에서 그것은 좋은 것입하는 일부의 매크로입니다.
기본적으로 나는 파일의 위치는 사용하고 싶 예:C:\insertfoldername\imagename.jpeg 에 나타나는 열서에서 스프레드시트(400 행).
이 Powepoint 템플릿을 사용하는 이미지 프레임(에서 하나 Powerpoint,는 케 당신을 가리켜 말한다.."그림 삽입 파일에서".
이러한 이미즈에서 오른쪽에 위치에 있습니다.
내가 무엇을 하고 싶은,Excel,붙여 넣기에서 이미지 파일의 경로는 엑셀에서 그리고 과거 그것으로는 특정 이미지 프레임입니다.
는 가능하게 될 것이라니까?

기본적으로 무언가가 이것을 할 것이다:
PPT.ActivePresentation.Slides(2).Shapes(3)LoadImage(spath)

아래 코드를 사용하고.
****음을 나타냅 파일 경로.jpg 파일로 설정한 제 3 열에 excel 스프레드시트에서도 합니다.

Sub CreateSlides()
'Dim the Excel objects
Dim objWorkbook As New Excel.Workbook
Dim objWorksheet As Excel.Worksheet

'Dim the File Path String
Dim strFilePath As String

'Dim the PowerPoint objects
Dim PPT As Object
Dim pptSlide As PowerPoint.Slide
Dim pptLayout As PowerPoint.CustomLayout
Dim pptNewSlide As PowerPoint.Slide
Dim str As String
Dim Title As String

Set PPT = GetObject(, "PowerPoint.Application")

PPT.Visible = True

'Get the layout of the first slide and set a CustomLayout object
Set pptLayout = PPT.ActivePresentation.Slides(1).CustomLayout

'Run the OpenFile function to get an Open File dialog box. It returns a String containing the file and path.
strFilePath = OpenFile()

'Open the Excel file
Set objWorkbook = Excel.Application.Workbooks.Open(strFilePath)

'Grab the first Worksheet in the Workbook
Set objWorksheet = objWorkbook.Worksheets(1)

'Loop through each used row in Column A
For i = 2 To objWorksheet.Range("A65536").End(xlUp).Row

Set PPT = GetObject(, "PowerPoint.Application")

Set pptNewSlide = PPT.ActivePresentation.Slides.AddSlide(PPT.ActivePresentation.Slides.Count + 1, pptLayout)

 'Get the number of columns in use on the current row
    Dim LastCol As Long
    Dim boldWords As String

    boldWords = "Line1: ,line2: ,Line3: ,Line4: "
    LastCol = objWorksheet.Rows(i).End(xlToRight).Column
    If LastCol = 16384 Then LastCol = 1 'For some reason if only column 1 has data it returns 16384, so correct it

    'Build a string of all the columns on the row
    str = ""
    str = "Line1: " & str & objWorksheet.Cells(i, 1).Value & Chr(13) & _
    "Line2: " & objWorksheet.Cells(i, 2).Value & Chr(13) & _
    "Line3: " & objWorksheet.Cells(i, 10).Value & Chr(13) & _
    "Line4: " & objWorksheet.Cells(i, 7).Value & Chr(13) & Chr(13) & _
    objWorksheet.Cells(i, 14).Value

 sfile = Cells(i, 3) & ".jpg" **** This is the jpg name

Set PPT = GetObject(, "PowerPoint.Application")

spath = "C:\test\"

'Write the string to the slide
pptNewSlide.Shapes(2).TextFrame.TextRange.Text = objWorksheet.Cells(i, 3).Value 'This enters the film Title
PPT.ActivePresentation.Slides(PPT.ActivePresentation.Slides.Count).Shapes(1).TextFrame.TextRange.Text = str


BoldSomeWords PPT.ActivePresentation.Slides(PPT.ActivePresentation.Slides.Count).Shapes(1), str, boldWords

'This is where I want to load in the Image.
'PPT.ActivePresentation.Slides(PPT.ActivePresentation.Slides.Count).Shapes(3).Picture = LoadPicture(spath) ' & sfile)
'PPT.ActivePresentation.Slides(2).Shapes(3)LoadImage((spath))

Next
End Sub

Function OpenFile()
'Dim the File Dialog object and string
Dim objFileDialog As FileDialog
Dim strFile As String

'Set the objFileDialog to an instance of the FileDialog object
Set objFileDialog = Application.FileDialog(msoFileDialogFilePicker)

'Set the Properties of the objFileDialog object
objFileDialog.AllowMultiSelect = False
objFileDialog.ButtonName = "Select"
objFileDialog.InitialView = msoFileDialogViewDetails
objFileDialog.Title = "Select Excel File"
objFileDialog.InitialFileName = "C:\"
objFileDialog.Filters.Clear
objFileDialog.Filters.Add "Excel", "*.xls; *.xlsx", 1
objFileDialog.FilterIndex = 1

'Show the FileDialog box
objFileDialog.Show

'Set strFile to the first record of the SelectedItems property of our FileDialog
strFile = objFileDialog.SelectedItems(1)

'Return the File Path string
OpenFile = strFile
End Function
도움이 되었습니까?

해결책

이것은 어떻게 당신이 추가 사진에서는 현재 열려 있는 PPT Picture PlaceHolders 사용합니다.
우리 사용되는 Early Binding 추가 Microsoft PowerPoint 14.0 Object Library 참조.

Edit1: 추가 DoEvents 고 일부는 설명

Sub ImportPictureInPlaceHolderFromExcel()

    Dim oPPt As PowerPoint.Application
    Dim oPPtSlide As PowerPoint.Slide
    Dim oPPtShp As PowerPoint.Shape

    '~~> Get hold of PPt instance meaning your currently open PPT presentation
    Set oPPt = GetObject(, "Powerpoint.Application")
    '~~> Reference the first slide which should contain picture placeholders
    Set oPPtSlide = oPPt.ActivePresentation.Slides(1)

    '~~> Now check each shape in slide
    For Each oPPtShp In oPPtSlide.Shapes
        '~~> You only need to work on Picture place holders
        If oPPtShp.PlaceholderFormat.Type = ppPlaceholderPicture Then
            With oPPtShp
                '~~> Now add the Picture
                '~~> For this example, picture path is in Cell A1
                oPPtSlide.Shapes.AddPicture Range("A1").Value, msoFalse, msoTrue, _
                                .Left, .Top, .Width, .Height
                '~~> Insert DoEvents here specially for big files, or network files
                '~~> DoEvents halts macro momentarily until the 
                '~~> system finishes what it's doing which is loading the picture file
                DoEvents
            End With
        End If
    Next

    Set oPPtSlide = Nothing
    Set oPPt = Nothing

End Sub

Sum-up:
1.우리의 PPT 응용 프로그램
2.우리는 잡아의 슬라이드와 모양 내의 슬라이드
3.지금 우리가 선택한 모양입 ppPlaceholderPicture 만 입력
4.우리가 사용하는 Shape Object's(ppPlaceholderPicture 형) .Top, .Left, .Width and .Height 으로 재산을 인수 모양의 컬렉션 .AddPicture 방법입니다.

거기 당신은 가서,당신은 추가 사진에서 당신의 PPT 사진이 자리 표시자를 가리킵니다.
희망이 당신이 필요합니다.

다른 팁

은 빈 그림이나 콘텐츠 자리 표시자가있는 슬라이드에 이미지를 추가 할 때 처럼 작동합니다. 항상 해당 자리 표시 자로 가고 크기를 조정할 수 있습니다.

다음과 같이 추가해야합니다.

osld.Shapes.AddPicture "Path", msoFalse, msoTrue, -1, -1
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top