When one stops the presentation by pressing ESC then PowerPoint stays open Sub

When one stops the presentation by pressing esc then

This preview shows page 514 - 517 out of 547 pages.

The following code will open a new instance of PowerPoint and display a presentation. When one stops the presentation (by pressing ESC, then PowerPoint stays open: Sub Open_And_Run_PPT1() Dim PPtObject As Object Dim pptPresentation As Object Set PPtObject = CreateObject ("PowerPoint.Application") PPtObject. Visible = True Set pptPresentation = _ PPtObject. Presentations . Open _ ("C:\temp\presentation example.ppt") PPtObject. ActivePresentation . SlideShowSettings . Run End Sub If you want PowerPoint to close after the presentation, then use code like the following:. Sub Open_And_Run_PPT_and_Close() Dim PPtObject As Object Dim pptPresentation As Object Set PPtObject = CreateObject ("PowerPoint.Application") PPtObject. Visible = True Set pptPresentation = _
Image of page 514
515 PPtObject. Presentations . Open _ ("C:\temp\presentation example.ppt") PPtObject. ActivePresentation . SlideShowSettings . Run While PPtObject.SlideShowWindows. Count = 1 DoEvents Wend PPtObject. ActivePresentation . Close PPtObject. Quit End Sub 33.18 Displaying A DOS Window The following will display a DOS window: Sub GiveMeDos() Dim taskID taskID = Shell ("Command.com", 1) End Sub 33.19 Getting Data From Access One of the most popular ways to do this is to use ADO or DAO to get the data and then to use Excel's CopyFromRecordset method to plop the data down. In Excel 97 and prior, the CopyFromRecordset method only supports DAO recordsets. However, Excel 2000 now supports ADO recordsets. The following illustrate two methods of getting data into Excel from Access: Sub GetDataWithDAO() Dim db As DAO. Database Dim rst As DAO. Recordset Set db = OpEndatabase ("C:\My Documents\SalesDb.mdb") Set rst = db. OpenRecordset ("SalesData") Range ("A1"). CopyFromRecordSet rst End Sub Sub GetDataWithADO() Dim cnt As New ADODB . Connection Dim rst As New ADODB . Recordset cnt. Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\My Documents\SalesDb.mdb;" rst. Open "Select * From SalesData", cnt Range ("A1"). CopyFromRecordSet rst End Sub If you need to get data from Access while running a Visual Basic macro, also check the following Microsoft Internet pages for information of using DAO to get data from Access. This page has a number of articles and a help file you can download.
Image of page 515
516 Microsoft knowledge base article Q149254 also gives an example of how to return DAO query results directly to a list box in Excel. The following is a posting on the Excel Visual Basic user group that gives some additional examples Question asked: "Looking for some advice relating to connecting to an Access database within excel" Response: If it's not a secured database, then you can simply call set rs = DBEngine.Opendatabase(DBPath, Options) - check the help file for details. You will, of course, have to select one of the DAO libraries in the VBA references dialog first - 3.5 is the recommended one, assuming you're on Office 97. If it is secured, you need to mess about with userid's and passwords.
Image of page 516
Image of page 517

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture