我需要在closures电源点应用程序时打开一个excel工作表

如果有人正在更新功率点,他们还需要更新Excel表格如何做到这一点? 我相信它可以通过macros来完成,但是我不擅长它。

Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim strFile As String Dim WB As Workbook If ThisWorkbook.Saved = False Then Dim DirFile As String DirFile = "C:\Users\tg2412\Documents\1.xlsx" If Len(Dir(DirFile)) = 0 Then MsgBox "File does not exist" Else Set WB = Workbooks.Open(DirFile) End If End If End Sub 

提前致谢…:)

你需要两件事情:

事件处理:

除非您打算以编程方式closures演示文稿,否则您的演示文稿需要处理演示文稿closures事件。 如果是,请跳到下一个标题。 Powerpoint事件并不像Excel那么简单。 这是一个开始的地方:

http://www.pptfaq.com/FAQ00004_Make_your_VBA_code_in_PowerPoint_respond_to_events.htm

Excel应用程序对象:

使用Excel应用程序对象从Powerpoint启动Excel:

 Dim Excel As Object Dim Workbook As Object Set Excel = CreateObject("Excel.Application") Excel.Visible = True 'Set this to false if you want Excel to work in the background 'Add more code to verify the path with dir() Set Workbook = Excel.Workbooks.Open("YourPathHere", True, False)