【问题标题】:Requirement for an Excel Macro to copy data from excel into power point using VBAExcel 宏要求使用 VBA 将数据从 excel 复制到 power point
【发布时间】:2012-06-01 19:55:47
【问题描述】:

我不熟悉 VBA,我需要这方面的帮助,我不知道需要多长时间以及我需要做什么,因此我们将不胜感激。

总结 - 基本上要求一个 excel 宏循环遍历将指定的某些 excel 工作表,并将这些工作表中的数据粘贴到现有的 power point 演示文稿中或创建一个新的演示文稿和将每个工作表数据作为图片粘贴到单独的幻灯片上。

关键细节如下:

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

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

3)。在版本 1 中,它只会创建一个新的 power point 幻灯片并粘贴到单个幻灯片中。我们可以指定高度和宽度要求来确定粘贴到 power point 时图片的大小。在这个版本中,我们可以为粘贴的图片指定一个通用的高度和宽度要求。

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

提前感谢您的帮助。 :)

【问题讨论】:

  • hmmm -> 我刚刚用谷歌搜索了“powerpoint vba 开始新的演示文稿”,你知道什么...我找到了这个Excel VBA to Create PP。这可能不是你所需要的 100%,但它肯定会让你在一个大的方面开始。在您让代码工作后,如果您需要帮助调整,请发布一个单独的问题,我们可以提供帮助!
  • Scott 已经给了你一个很好的链接。但是,我想补充一个非常重要的事实。如果您打算使该文件同时适用于 2007/2010 年,则不要按照链接中的说明进行早期绑定,而是选择后期绑定。

标签: vba excel powerpoint


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多