打开Excel文件的VB代码示例: ``` Dim xlApp As Excel.Application Dim xlWorkbook As Excel.Workbook Dim xlSheet As Excel.Worksheet Set xlApp = New Excel.Application xlApp.Visible = True Set xlWorkbook = xlApp.Workbooks.Open("d:hao1.xls") Set xlSheet = xlWorkbook.Sheets(1) ``` 打开PPT文件的VB代码示例: 1. 使用Windows的函数ShellExecute来打开文件。在程序中声明该函数,并通过以下代码来打开PPT文件: ```vb Public Declare Function ShellExecute Lib "shell32" ( _ ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long ShellExecute(Me.hwnd, vbNullString, "d:emp827.ppt", vbNullString, vbNullString, vbNullString, 1) ``` 2. 使用VB自带的函数SHELL来打开文件。以下代码展示了如何使用SHELL来打开PPT文件: ```vb Public Declare Function SHELL Lib "user32" ( _ ByVal cmd As Long, _ ByVal args As String, _ ByVal application As Long, _ ByVal flags As Long) As Long SHELL 1, "d:emp827.ppt", 1, 0 ``` 其中,第一参数cmd表示使用SHELL打开文件的操作码,第二参数args表示打开时的参数字符串,第三参数application表示应用程序句柄,第四参数flags表示打开选项。