簡體   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