2017-12-09 2 views
0

VBA를 처음 사용하며 Excel에서 수동으로 파워 포인트 슬라이드로 붙여 넣기 데이터를 복사합니다. 각 PowerPoint 슬라이드에는 차트, 텍스트 상자 및 표가 있습니다. 따라서 엑셀 시트에 데이터를 복사하고 원본 서식과 텍스트 상자 및 표의 데이터를 변경하는 기능을 잃지 않고 PowerPoint에 붙여 넣기를 원합니다. 엑셀 시트를 그림으로 복사하는 매크로 아래에 있습니다. 하지만 내 문제는 복사 된 데이터를 원본 형식 (예 : 표, 텍스트 상자, 차트 등)에 붙여 넣을 수있는 방법입니다. 어떤 도움이라도 대단히 감사합니다.VBA를 사용하여 모든 시트의 Excel 파일에서 모든 시트를 PowerPoint 파일에 붙여 넣기 복사

Sub WorkbooktoPowerPoint() 

    'Step 1: Declare your variables 
    Dim pp As Object 
    Dim PPPres As Object 
    Dim PPSlide As Object 
    Dim xlwksht As Worksheet 
    Dim MyRange As String 
    Dim MyTitle As String 

    'Step 2: Open PowerPoint, add a new presentation and make visible 

    Set pp = CreateObject("PowerPoint.Application") 
    Set PPPres = pp.Presentations.Add 
    pp.Visible = True 

    'Step 3: Set the ranges for your data and title 

    MyRange = "A1:H40" '<<<Change this range 

    'Step 4: Start the loop through each worksheet 

    For Each xlwksht In ActiveWorkbook.Worksheets 
     xlwksht.Select 
     Application.Wait (Now + TimeValue("0:00:1")) 

    'Step 5: Copy the range as picture 

     xlwksht.Range(MyRange).CopyPicture _ 
      Appearance:=xlScreen, Format:=xlPicture 

    'Step 6: Count slides and add new blank slide as next available slide number 
    '(the number 16 represents the enumeration for a Blank Slide) 

     SlideCount = PPPres.Slides.Count 
     Set PPSlide = PPPres.Slides.Add(SlideCount + 1, 16) 
     PPSlide.Select 

    'Step 7: Paste the picture and adjust its position 

     PPSlide.Shapes.Paste.Select 
     pp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True 
     pp.ActiveWindow.Selection.ShapeRange.Top = 1 
     pp.ActiveWindow.Selection.ShapeRange.Left = 1 
     pp.ActiveWindow.Selection.ShapeRange.Width = 500 

    'Step 8: Add the title to the slide then move to next worksheet 

    Next xlwksht 

    'Step 9: Memory Cleanup 

    pp.Activate 
    Set PPSlide = Nothing 
    Set PPPres = Nothing 
    Set pp = Nothing 
End Sub 

답변

0

copypicture의 copychart 방법을 사용하십시오. 차트의 형식과 데이터를 유지합니다.

관련 문제