PC Review


Reply
Thread Tools Rate Thread

beginner wants to write macro that run when presentation is viewed

 
 
mscir
Guest
Posts: n/a
 
      6th May 2007
I am a VB6 programmer but a complete ppt beginner. I have two things I'm
trying to accomplish:
1) write a small text file that contains the number of times a
presentation has been viewed, updating the file each time. and

2) displaying the number of times it's been viewed somewhere on the
presentation.

I know the VB subroutine code for writing and reading a file, but I
don't know how to call the subroutine each time the program is run, and
I don't know how to display the number of times the presentation has
been viewed.

Any help or urls would be greatly appreciated,
Mike
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9obiBXaWxzb24=?=
Guest
Posts: n/a
 
      6th May 2007
This should help with responding to events in ppt.
http://pptfaq.com/FAQ00004.htm
--
Amazing PPT Hints, Tips and Tutorials-http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


"mscir" wrote:

> I am a VB6 programmer but a complete ppt beginner. I have two things I'm
> trying to accomplish:
> 1) write a small text file that contains the number of times a
> presentation has been viewed, updating the file each time. and
>
> 2) displaying the number of times it's been viewed somewhere on the
> presentation.
>
> I know the VB subroutine code for writing and reading a file, but I
> don't know how to call the subroutine each time the program is run, and
> I don't know how to display the number of times the presentation has
> been viewed.
>
> Any help or urls would be greatly appreciated,
> Mike
>

 
Reply With Quote
 
Steve Rindsberg
Guest
Posts: n/a
 
      6th May 2007
In article <c-(E-Mail Removed)>, Mscir wrote:
> I am a VB6 programmer but a complete ppt beginner. I have two things I'm
> trying to accomplish:
> 1) write a small text file that contains the number of times a
> presentation has been viewed, updating the file each time. and
>
> 2) displaying the number of times it's been viewed somewhere on the
> presentation.
>
> I know the VB subroutine code for writing and reading a file, but I
> don't know how to call the subroutine each time the program is run, and
> I don't know how to display the number of times the presentation has
> been viewed.


Getting code to run when a presentation is viewed is tricky. There's no
built-in way to do this in PPT as there is in Word/Excel.

You can trap events with an addin (see the link John posted) or, depending on
circumstances, you could have a "Start the Show" button on the first slide
trigger a macro that does the counter tracking and advances to the next slide.

As far as the counter tracking:

You can use a text file if you like, and I can imagine some good reasons for
doing so, but it might be simpler to keep the data attached to the PPT file
itself.

If you want to do that, you can use tags on the presentation itself:

Dim sTimesViewed as String

' Read the TimesViewed tag
sTimesViewed = ActivePresentation.Tags("TimesViewed")

If Len(sTimesViewed) > 0 then
' Increment it
sTimesViewed = Cstr(Clng(sTimesViewed) + 1)
Else
' Never viewed before, no tag there so start it at one
sTimesViewed = 1
End if

' And write back the tag
Call ActivePresentation.Tags.Add("TimesViewed", sTimesViewed)

' update the display
' supposing you have a shape named "Counter" on Slide 1:
ActivePresentation.Slides(1).Shapes("Counter").TextFrame.TextRange.Text = _
sTimesViewed

' Make sure changes are saved to PPT file
ActivePresentation.Save

========================================




-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


 
Reply With Quote
 
Mike Scirocco
Guest
Posts: n/a
 
      7th May 2007
John Wilson wrote:
> This should help with responding to events in ppt.
> http://pptfaq.com/FAQ00004.htm


John,

That is very useful, thanks very much!

Mike
 
Reply With Quote
 
Mike Scirocco
Guest
Posts: n/a
 
      7th May 2007
Steve Rindsberg wrote:
> In article <c-(E-Mail Removed)>, Mscir wrote:
>> I am a VB6 programmer but a complete ppt beginner. I have two things I'm
>> trying to accomplish:
>> 1) write a small text file that contains the number of times a
>> presentation has been viewed, updating the file each time. and
>>
>> 2) displaying the number of times it's been viewed somewhere on the
>> presentation.
>>
>> I know the VB subroutine code for writing and reading a file, but I
>> don't know how to call the subroutine each time the program is run, and
>> I don't know how to display the number of times the presentation has
>> been viewed.

>
> Getting code to run when a presentation is viewed is tricky. There's no
> built-in way to do this in PPT as there is in Word/Excel.
>
> You can trap events with an addin (see the link John posted) or, depending on
> circumstances, you could have a "Start the Show" button on the first slide
> trigger a macro that does the counter tracking and advances to the next slide.
>
> As far as the counter tracking:
>
> You can use a text file if you like, and I can imagine some good reasons for
> doing so, but it might be simpler to keep the data attached to the PPT file
> itself.
>
> If you want to do that, you can use tags on the presentation itself:
>
> Dim sTimesViewed as String
>
> ' Read the TimesViewed tag
> sTimesViewed = ActivePresentation.Tags("TimesViewed")
>
> If Len(sTimesViewed) > 0 then
> ' Increment it
> sTimesViewed = Cstr(Clng(sTimesViewed) + 1)
> Else
> ' Never viewed before, no tag there so start it at one
> sTimesViewed = 1
> End if
>
> ' And write back the tag
> Call ActivePresentation.Tags.Add("TimesViewed", sTimesViewed)
>
> ' update the display
> ' supposing you have a shape named "Counter" on Slide 1:
> ActivePresentation.Slides(1).Shapes("Counter").TextFrame.TextRange.Text = _
> sTimesViewed
>
> ' Make sure changes are saved to PPT file
> ActivePresentation.Save
>
> ========================================
> Steve Rindsberg, PPT MVP
> PPT FAQ: www.pptfaq.com
> PPTools: www.pptools.com


Thanks Steve,

that's very useful, much nicer than a text file, and automatically moves
with the presentation.

Mike
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I save my PP presentation to be viewed on t.v. from DVD? ArtWench Microsoft Powerpoint 4 16th Feb 2010 01:08 PM
can saved presentation be viewed on dvd player? Question about powerpoint Microsoft Powerpoint 4 26th Jul 2009 04:26 AM
Re: (Write Password) Read Only Presentation with Macro Write Capabilit Steve Rindsberg Microsoft Powerpoint 0 4th Jan 2007 09:49 PM
Output a presentation to a DVD so it can be viewed on TV THOMAS CONLON Microsoft Powerpoint 3 16th Feb 2006 01:56 PM
Securing a PowerPoint presentation to be viewed on the web? Rosalyn Microsoft Powerpoint 2 21st Jun 2004 05:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:06 AM.