M
Mike M.
Tested with PPT 2002 and 2003. I have an addin that puts the current
date/time into a text box. PowerPoint crashes and throws up an error dialog
at random intervals from 1/2 hour to several hours. My presentation is
simple text with a "tagged" shape (text box) that my addin looks for and
sticks the time/date into. I am wondering if it is the way I put the text
into the shape. Any comments on the following code? Do I need to delete
the text in the text range each time? Thanks.
Public WithEvents PPTEvent As Application
Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim slide As PowerPoint.slide
Dim shp As PowerPoint.Shape
Dim dateStr As String
Dim timeStr As String
' This contains the current slide.
Set slide = Wn.View.slide
' Check each shape for our special shape
For Each shp In slide.Shapes
With shp
If (.Tags.Count > 0) Then
' Check for our date/time shape
If (.Tags.Name(1) = MY_SPECIAL_NAME) Then
' Returns "Wednesday, Jan 27 1993".
dateStr = Format(Date, "dddd, mmm d yyyy")
' format time as desired
' Returns "5:04 PM".
timeStr = Format(Time, "hh:mm AMPM")
.TextFrame.TextRange.text = dateStr & " " & timeStr
End If
End If ' end if tags > 0
End With
Next shp
End Sub
date/time into a text box. PowerPoint crashes and throws up an error dialog
at random intervals from 1/2 hour to several hours. My presentation is
simple text with a "tagged" shape (text box) that my addin looks for and
sticks the time/date into. I am wondering if it is the way I put the text
into the shape. Any comments on the following code? Do I need to delete
the text in the text range each time? Thanks.
Public WithEvents PPTEvent As Application
Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim slide As PowerPoint.slide
Dim shp As PowerPoint.Shape
Dim dateStr As String
Dim timeStr As String
' This contains the current slide.
Set slide = Wn.View.slide
' Check each shape for our special shape
For Each shp In slide.Shapes
With shp
If (.Tags.Count > 0) Then
' Check for our date/time shape
If (.Tags.Name(1) = MY_SPECIAL_NAME) Then
' Returns "Wednesday, Jan 27 1993".
dateStr = Format(Date, "dddd, mmm d yyyy")
' format time as desired
' Returns "5:04 PM".
timeStr = Format(Time, "hh:mm AMPM")
.TextFrame.TextRange.text = dateStr & " " & timeStr
End If
End If ' end if tags > 0
End With
Next shp
End Sub