View Single Post
 
Old 01-13-2016, 08:21 PM
zcu zcu is offline Windows 8 Office 2010 64bit
Novice
 
Join Date: Jan 2016
Posts: 2
zcu is on a distinguished road
Default object variable set or not??? Challenging \ Perplexing

Hi

I'm a newbie please be nice

I'm trying to write an if then else and I'm referring to the same variable. Yet when the if is true the variable is an error "not set".

But if it is false the code works perfectly.

Code:
For i = 1 To 10
'get student name from worksheet
x = ox.Worksheets("data").Cells(21, 2 + i).Text

With ActivePresentation.Slides(2).Shapes("name" & i)
.TextFrame.TextRange.Text = x
End With
'check if student pic in file

On Error Resume Next
xipath = Dir("C:\ProgramData\Learning Excellence\Behavior\Pictures\" & x & ".jpg")
On Error GoTo 0

' if not = forecolor white
If xipath = "" Then
With ActivePresentation.Slides(2).Shapes("pic" & i)
.Fill.ForeColor.RGB = RGB(255, 255, 255)
End With

' if yes = forecolor picture
Else
With ActivePresentation.Slides(2).Shapes("pic" & i)
.Fill.UserPicture ("C:\ProgramData\Learning Excellence\Behavior\Pictures\" & x & ".jpg")
End With
End If
   Next i
Reply With Quote