質問

て制作しました一部のコードをExcel VBAをPowerPointプレゼンテーション1スライドのため、各行のエクセル、移植細なテキストボックスにトークをしました。
私を追加したいすべての画像に一致する。これらはすべての通報なチャートなど。
する方法を教えてくださいこれでいこexcel、またはほうが良いのはこのPowerpoint VBAです。
Eitherway、誰にでも助けることができるようになえる一部のコードをどうい下さい。
画像のフレームに存在するパワーポイント2枚のスライド(転移又はとか付けたやつでも強い
感謝です。

P.Sを使用していPowerPointやExcel2010の場合Windows7です。


があるのではないことからExcel?自分のコードを、Excelとのないその取り組みの一環として、クリックします。
基本的にはいファイルのロケーションを利用したいなどC:\insertfoldername\imagename.jpeg 表示カラムHスプレッドシートの約400rows).
のPowepointテンプレートを使用している画像フレーム(パワーポイントは、wehnお伺い.."挿入画像ファイルから".
これらは既にサイズは右ます。
何をしたいのは、Excelに貼り付け画像からのパスをフルパスで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

総括:
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