要求Excel宏使用VBA将数据从Excel复制到电源点

时间:2012-06-01 19:55:48

标签: vba excel-vba powerpoint-vba excel

我不熟悉VBA,我需要帮助,我不知道需要多长时间以及我需要做什么,所以任何帮助都会受到赞赏。

摘要 - 基本上要求excel宏循环浏览某些指定的Excel工作表,并将每个工作表中的数据粘贴到现有的power point演示文稿中或创建新的演示文稿将每个工作表数据作为图片粘贴到单张幻灯片上。

关键详情如下:

1 )。每个Excel工作表都包含1个Excel表或Excel图表。

2 )。 Excel表格或图表将在Excel中围绕它们设置打印区域。这就是VBA代码将如何知道每张表上要复制的内容。它需要复制每张纸上的设置打印区域并粘贴在单独的电源点幻灯片中作为图片。

第3 )。在版本1中,它将创建一个新的功率点幻灯片并粘贴到单个幻灯片中。我们可以指定高度和宽度要求,以确定粘贴到功率点时图片的大小。在此版本中,我们可以为粘贴的图片指定通用的高度和宽度要求。

4 )。代码需要与Excel和PowerPoint 2010一起使用。我相信2007年非常相似,为这些版本编写的代码也适用于2010年。

提前感谢您的帮助。 :)

1 个答案:

答案 0 :(得分:1)

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