2017-07-28 96 views
1

上午在使用Excel VBA中。這裏功率點自動化工作是代碼Excel VBA中多量程到PowerPoint

'List of PPT Slides to Paste to 
MySlideArray = Array(2, 3, 4, 5, 6) 

'List of Excel Ranges to Copy from 
MyRangeArray = Array(Sheet1.Range("$A$6:$I$16"), 
Sheet1.Range("$A$6:$I$8,$A$17:$I$33"), _ 
    Sheet1.Range("$A$6:$I$16"), Sheet1.Range("$A$6:$I$16"), 
Sheet1.Range("$A$6:$I$16")) 

'Loop through Array data 
For x = LBound(MySlideArray) To UBound(MySlideArray) 
'Copy Excel Range 
MyRangeArray(x).Copy 

'Paste to PowerPoint and position 
    On Error Resume Next 
    Set shp = 
myPresentation.Slides(MySlideArray(x)).Shapes.PasteSpecial(DataType:=2) 
'Excel 2007-2010 
    Set shp = PowerPointApp.ActiveWindow.Selection.ShapeRange 'Excel 2013 
    On Error GoTo 0 

的代碼工作,唯一的問題是代碼

Sheet1.Range("$A$6:$I$8,$A$17:$I$33") 

不不排除所述單元格,只需包含所有內容

回答

1

您需要隱藏您不想在照片中拍攝的行。試試這個:

For x = LBound(MySlideArray) To UBound(MySlideArray) 
    With MyRangeArray(x) 
    .Parent.Rows.Hidden = True ' <-- hide all rows 
    .EntireRow.Hidden = False  ' <-- show range's rows 
    .Copy 
    Set shp = myPresentation.Slides(MySlideArray(x)).Shapes.PasteSpecial(DataType:=2) 
    .Parent.Rows.Hidden = False ' <-- show back all rows 
    End With 
Next 

enter image description here

+0

謝謝你這麼多 –

+0

如何指定每個slide.How的大小做我格式化每個幻燈片? –