Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources] - نسخه متنی

Alison Balter

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



Controlling PowerPoint from Access


Believe it or not, you can even control PowerPoint using automation. You can create a presentation, print a presentation, or even run a slide show directly from Access.

PowerPoint launches as a hidden window. To make PowerPoint visible, you must set the Visible property of AppWindow to True. Destroying the PowerPoint object variable does not terminate the PowerPoint application.

NOTE

You can find details of the PowerPoint object model in Microsoft PowerPoint Visual Basic Reference in PowerPoint Help. You should review this object model before attempting to communicate with PowerPoint.

The code shown in Listing 22.10 is located under the Click event of the cmdChangePicture command button on frmOLEToPowerPoint, which is shown in Figure 22.11. Figure 22.12 shows the resulting PowerPoint slide.

Listing 22.10 Using Select Picture

Private Sub cmdChangePicture_Click()
'Display Open common dialog
dlgCommon.ShowOpen
'If the user selected a file, set the SourceDoc
'property of the OLE control to the selected document
If Len(dlgCommon.Filename) Then
olePicture.SourceDoc = dlgCommon.Filename
'Designate that you wish to link to
'the selected document
olePicture.Action = acOLECreateLink
End If
End Sub
Figure 22.11. The form used to create a PowerPoint slide.


Figure 22.12. A PowerPoint slide created using automation.


The code in the Click event of cmdChangePicture invokes the File Open common dialog box so that the user can select a picture to be added to the slide. The Filename property returned from this dialog box is used as the SourceDoc property for the automation object. The new picture is then linked to the automation object.

Listing 22.11 shows the routine that creates the PowerPoint slide.

Listing 22.11 Creating the PowerPoint Slide

Private Sub cmdMakePPTSlide_Click()
Dim objPresentation As PowerPoint.Presentation
Dim objSlide As PowerPoint.Slide
'Ensure that both the title and the picture are selected
If IsNull(Me.txtTitle) Or Me.olePicture.SourceDoc = " Then
MsgBox "A Title Must Be Entered, and a Picture Selected Before Proceeding"
Else
'Create instance of PowerPoint application
Set mobjPPT = New PowerPoint.Application
'Make instance visible to user
mobjPPT.Visible = True
'Add a Presentation
Set objPresentation = mobjPPT.Presentations.Add
'Add a Slide
Set objSlide = objPresentation.Slides.Add(1, ppLayoutTitleOnly)
'Change the Slide Background
objSlide.Background.Fill.ForeColor.RGB = RGB(255, 100, 100)
'Modify the Slide Title
With objSlide.Shapes.Title.TextFrame.TextRange
.Text = Me.txtTitle
.Font.Color.RGB = RGB(0, 0, 255)
.Font.Italic = True
End With
'Add the OLE Picture
objSlide.Shapes.AddOLEObject _
Left:=200, Top:=200, Width:=500, Height:=150, _
Filename:=olePicture.SourceDoc, link:=True
End If
cmdMakePPTSlide_Exit:
Set objPresentation = Nothing
Set objSlide = Nothing
Exit Sub
cmdMakePPTSlide_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Resume cmdMakePPTSlide_Exit
End Sub

The routine begins by creating an instance of PowerPoint. The code makes the instance visible. It adds a presentation to the PowerPoint object, and then adds a slide to the presentation. The code modifies the background fill of the slide. It then customizes the text, color, and italic properties of the title object. Finally, it uses the SourceDoc property of the olePicture object to create an automation object, which it adds to the slide.


/ 544