Convert PowerPoint refrence to late binding in Access

  • Thread starter biganthony via AccessMonster.com
  • Start date
B

biganthony via AccessMonster.com

Hi,

The following code below works with a Reference set to PowerPoint. Could
someone help me convert the folowing code to late binding? My attempt is
below the original code.

ORIGINAL CODE***************

Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation


'Open up a recordset on the Employees table.
Set db = CurrentDb
Set rs = db.OpenRecordset("Employees", dbOpenDynaset)

'Open up an instance of Powerpoint.
Set ppObj = New PowerPoint.Application
Set PPPres = ppObj.Presentations.Add

'Setup the set of slides and populate them with data from the employee
table.
With PPPres

While Not rs.EOF

With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutText)

.Shapes(1).TextFrame.TextRange.Text = CStr(rs.Fields
("EmployeeCode").value)
.SlideShowTransition.EntryEffect = ppEffectBlank

With .Shapes(2).TextFrame.TextRange

.Text = "FTE = " & CStr(rs.Fields("EmployeeFirst").value)
& vbCrLf & _
"Allowance = " & TeachersAllowance & vbCrLf & _
"Teacher's Load = " & CStr(rs.Fields("EmployeeLast").
value) & vbCrLf & _
"Teaching Value = " & CStr(rs.Fields("EmployeeHours").
value) & vbCrLf & _
"Teaching Value = " & CStr(rs.Fields("EmployeePosition").
value) & vbCrLf & _
"Teaching Value = " & CStr(rs.Fields("EmployeeRate").
value)

.Characters.Font.Color.RGB = RGB(0, 0, 255)
.Characters.Font.Shadow = True
.Characters.Font.Size = 26

End With

.Shapes(1).TextFrame.TextRange.Characters.Font.Size = 30

End With

rs.MoveNext

Wend

End With

'run the show.
PPPres.SlideShowSettings.Run

********************************

This is my attempt. When I run it in the immediate window, I get an error
message saying "Object Required" (Error Number 424).


MY ATTEMPT ****************

Dim PPApp As Object
Dim PPPres As Object
Dim PPSlide As Object
Dim db As Database, rs As Recordset

'Open up a recordset on the Employees table.
Set db = CurrentDb
Set rs = db.OpenRecordset("Employees", dbOpenDynaset)

Set PPApp = CreateObject("Powerpoint.Application")
Set PPPres = PPApp.Presentations.Add

With PPPres

While Not rs.EOF

With pptPres.Slides

Set PPSlide = .Add(rs.AbsolutePosition + 1, ppLayoutText)

.Shapes(1).TextFrame.TextRange.Text = CStr(rs.Fields
("EmployeeCode").value)
.SlideShowTransition.EntryEffect = ppEffectBlank

With PPSlide

.Text = "FTE = " & CStr(rs.Fields("EmployeeFirst").value)
& vbCrLf & _
"Allowance = " & TeachersAllowance & vbCrLf & _
"Teacher's Load = " & CStr(rs.Fields("EmployeeLast").
value) & vbCrLf & _
"Teaching Value = " & CStr(rs.Fields("EmployeeHours").
value) & vbCrLf & _
"Teaching Value = " & CStr(rs.Fields("EmployeePosition").
value) & vbCrLf & _
"Teaching Value = " & CStr(rs.Fields("EmployeeRate").
value)

.Characters.Font.Color.RGB = RGB(0, 0, 255)
.Characters.Font.Shadow = True
.Characters.Font.Size = 26

End With

.Shapes(1).TextFrame.TextRange.Characters.Font.Size = 30

End With

rs.MoveNext

Wend

End With

'run the show.
PPPres.SlideShowSettings.Run

Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing


I would appreciate any help.

Thanks
Anthony
 
D

Douglas J. Steele

What line of code raises the error? One thing that pops out is that if
you've removed the reference to PowerPoint, you're going to have to provide
a value for ppLayoutText, as Access has no idea what that constant is.
 
B

biganthony via AccessMonster.com

I looked at my code and had a mistake in it.

"With pptPres.Slides" should read "With PPPres.Slides"

Also I changed:

Set PPSlide = Add(rs.AbsolutePosition + 1, ppLayoutText) to

Set PPSlide = .Add(rs.AbsolutePosition + 1, 2)

I found that the constant "ppLayoutText" has a value of 2

Now I am getting the following error:

"Object doesn't support this property or method. Error number 438"


Anthony

What line of code raises the error? One thing that pops out is that if
you've removed the reference to PowerPoint, you're going to have to provide
a value for ppLayoutText, as Access has no idea what that constant is.
[quoted text clipped - 137 lines]
Thanks
Anthony
 
B

biganthony via AccessMonster.com

Forgot to mention it Doug, the new error is happening on this line:

.SlideShowTransition.EntryEffect = ppEffectBlank


Anthony


I looked at my code and had a mistake in it.

"With pptPres.Slides" should read "With PPPres.Slides"

Also I changed:

Set PPSlide = Add(rs.AbsolutePosition + 1, ppLayoutText) to

Set PPSlide = .Add(rs.AbsolutePosition + 1, 2)

I found that the constant "ppLayoutText" has a value of 2

Now I am getting the following error:

"Object doesn't support this property or method. Error number 438"

Anthony
What line of code raises the error? One thing that pops out is that if
you've removed the reference to PowerPoint, you're going to have to provide
[quoted text clipped - 5 lines]
 
R

Rick Brandt

biganthony said:
Forgot to mention it Doug, the new error is happening on this line:

SlideShowTransition.EntryEffect = ppEffectBlank

You have to replace ALL of the PowerPoint constants with their actual
values. ppEffectBlank means something with early binding. It does not with
late binding.
 
B

biganthony via AccessMonster.com

I commented out the line with ppEffBlank and I still get the error message
"Object doesn't support this property or method."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top