简体   繁体   中英

Requirement for an Excel Macro to copy data from excel into power point using VBA

I'm not familiar with VBA and I needed help with this, I don't know how long it would take and what I need to do so any help would be appreciated.

Summary - Basically requirement for an excel macro to loop through certain excel sheets which would be specified and paste the data from each of these sheets into either an existing power point presentation or create a new presentation and paste each of the sheet data as picture on an individual slide.

Key Details are as follows:

1 ). Each Excel worksheet would either contain 1 excel table or Excel chart.

2 ). The Excel table or chart will have a print area set around them in Excel. This is how the VBA code will know what to copy on each sheet. It needs to copy the set print area on each sheet and paste in a separate power point slide as picture.

3 ). In version 1 it will just create a new power point slide and paste into an individual slides. We can specify the height and width requirements to determine the size of picture when pasted into power point. In this version we can specify a generic height and width requirement for the pasted picture.

4 ). Code needs to work with Excel and PowerPoint 2010. I believe 2007 is very similar and the code written for those versions would work on 2010 also.

Thanks for the help in advance. :)

Option Compare Database

Private Sub Command3_Click()
Call findField(Text1.Value)
End Sub

Public Function findField(p_myFieldName)
    Dim db As Database, _
        tb As TableDef, _
        fd As Field

    Set db = CurrentDb

    ''''''Clearing the contents of the table
    DoCmd.RunSQL " Delete from Field_Match_Found"

    For Each tb In db.TableDefs
        For Each fd In tb.Fields
            If fd.Name = p_myFieldName Then

                'MsgBox ("Table " & tb.Name & " has the field " & fd.Name)

                strsql = "INSERT INTO Field_Match_Found Values (""" & tb.Name & """, """ & fd.Name & """)"
                DoCmd.RunSQL strsql

            End If
        Next fd
    Next tb
    Set fd = Nothing
    Set tb = Nothing
    Set db = Nothing

    ''''''''Checking if any match found for the specified field or not
    If DCount("Table_name", "Field_Match_Found") = 0 Then
    MsgBox ("No match found in your database")
    Else
    MsgBox ("Check Table Field_Match_Found for your output")
    End If

    '''''''''''clearing the text box for the next time
    Me.Text1.Value = ""

End Function


Private Sub Form_Load()
Me.Text1.Value = ""
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM