繁体   English   中英

我需要在关闭PowerPoint应用程序的同时打开excel工作表

[英]I need to open an excel worksheet while closing an power point application

如果有人要更新电源点,他们还需要更新Excel工作表如何做到这一点? 我敢肯定它可以通过宏来完成,但是我不擅长。请帮助我...

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

提前致谢...:)

您需要两件事:

事件处理:

Powerpoint需要处理演示文稿关闭事件,除非您打算以编程方式关闭它。 如果是这样,请跳到下一个标题。 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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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