Convert excel information to PPT in batches

foreword

In the work, we often encounter statistical work of a large amount of data, which is time-consuming and labor-intensive. We usually use excel to make this information into form information. In addition to statistical analysis, the report is also facing degradation. At this time, it is necessary to convert excel to PPT for reporting. If you copy and paste one by one, it will really make people crash.

1. Analyze data

 This is a group of survey information on sewage outlets entering the river, the purpose of which is to introduce the specific situation of each outlet. It is best to have a port and a PPT.

Two, use vba

You don't need to know how to program, just ask chatgpt.

Here are my questions:

The excel table has multiple rows and columns, the outline level of the first column is 1, and the outline level of the second and subsequent columns is 2, please convert it to word outline mode

Below is the code

Sub ExportToWordOutline()
    Dim wdApp As Object
    Dim wdDoc As Object
    Dim wdRange As Object
    Dim rng As Range
    Dim i As Long, j As Long
    
    ' 创建Word应用程序对象
    Set wdApp = CreateObject("Word.Application")
    wdApp.Visible = True
    
    ' 创建新的Word文档
    Set wdDoc = wdApp.Documents.Add
    
    ' 获取Excel中的数据范围
    Set rng = ThisWorkbook.Sheets("Sheet1").UsedRange
    
    ' 将数据复制到Word大纲视图中
    Set wdRange = wdDoc.Range
    For i = 1 To rng.Rows.Count
        wdRange.Paragraphs.Add
        wdRange.Paragraphs.Last.Range.Text = rng.Cells(i, 1).Value
        wdRange.Paragraphs.Last.outlineLevel = 1
        
        For j = 2 To rng.Columns.Count
            wdRange.Paragraphs.Add
            wdRange.Paragraphs.Last.Range.Text = rng.Cells(i, j).Value
            wdRange.Paragraphs.Last.outlineLevel = 2
        Next j
    Next i
    
    ' 释放对象
    Set rng = Nothing
    Set wdRange = Nothing
    Set wdDoc = Nothing
    Set wdApp = Nothing
End Sub

3. Word outline to PPT

Generate word outline view after running

 ppt New ppt - slides from outline

The effect is as follows

 4. Adjust the layout of PPT

View - Slide Master

Select the corresponding format and modify it. Finally achieve the effect you want.

 

 

Guess you like

Origin blog.csdn.net/weixin_42984235/article/details/131405424