I am making a database which has its output in PowerPoint. I have set it up so that each field value is shown on a different slide with the code for each slide like this:
This works fine until a filed is blank (which they sometimes are) where it then crashes with error 94 invalid use of null. What I was thinking was putting the whole thing above in an If-then-else statement so that a blank field does not produce a slide, something like:
This doesn't work though - at least not like I have written it! Any suggestions?
Code:
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutLargeObject)
.FollowMasterBackground = False
.Background.Fill.Solid
.Background.Fill.ForeColor.RGB = RGB(0, 0, 0)
With .Shapes(1).TextFrame.TextRange
.Text = CStr(rs.Fields("Song 1 chosen_Verse 2").Value)
.Characters.Font.Color.RGB = RGB(255, 255, 255)
.Characters.Font.Size = 36
.ParagraphFormat.Bullet = False
.ParagraphFormat.Alignment = ppAlignCenter
End With
End With
This works fine until a filed is blank (which they sometimes are) where it then crashes with error 94 invalid use of null. What I was thinking was putting the whole thing above in an If-then-else statement so that a blank field does not produce a slide, something like:
Code:
If IsNull(CStr(rs.Fields("Song 1 chosen_Verse 2").Value)) Then
Else
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutLargeObject)
.FollowMasterBackground = False
.Background.Fill.Solid
.Background.Fill.ForeColor.RGB = RGB(0, 0, 0)
With .Shapes(1).TextFrame.TextRange
.Text = CStr(rs.Fields("Song 1 chosen_Verse 2").Value)
.Characters.Font.Color.RGB = RGB(255, 255, 255)
.Characters.Font.Size = 36
.ParagraphFormat.Bullet = False
.ParagraphFormat.Alignment = ppAlignCenter
End With
End With
End If
This doesn't work though - at least not like I have written it! Any suggestions?