Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / November 2007

Tip: Looking for answers? Try searching our database.

Help In Inserting Slide Number Using VBA Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary - 21 Nov 2007 15:15 GMT
I currently generate power point slide files using VBA Code from MS Access.  
Once I have the power point file (ppt file), I can insert slide number and it
appears at the lower right corner of my slides manually.  I want to do this
all from VBA Code.

Can someone show me how this can be done using VBA Code???

I have already recorded the macro for Insert Slide Number.  I don't know how
to insert a macro into a ppt file via VBA Code.   Even if I insert the macro
code in, I must run this code to take effect.   How can I do this via VBA
code too.  

Is there a way to run the VBA Code like on open event??

Your help is deeply appreicated.

Gary
David M. Marcovitz - 21 Nov 2007 15:44 GMT
Gary,

I'm not sure I understand. Why do you want to run the VBA code from
PowerPoint. If you're running the VBA code in Access to create the show,
can't you run the code from Access to also add the page numbers. Just
note, what you get out of recording a macro is rarely directly usable.

--David

Signature

David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

> I currently generate power point slide files using VBA Code from MS
> Access.  Once I have the power point file (ppt file), I can insert
[quoted text clipped - 13 lines]
>
> Gary
Brian Reilly, MVP - 21 Nov 2007 17:18 GMT
Gary,
David is correct. If you are already running PPT from Access VBA code
then run the Insert Slide # code in a PPT file from Access. Sounds
like you already have the PPT application referenced, so just wrap the
Insert Slide # code somewhere inside that.

Or are we missing something in your question?

Brian Reilly, MVP

>I currently generate power point slide files using VBA Code from MS Access.  
>Once I have the power point file (ppt file), I can insert slide number and it
[quoted text clipped - 13 lines]
>
>Gary
Gary - 21 Nov 2007 17:42 GMT
I need the ability for users who open Power Point and reorder the slides.  
Currently, I do generate slide number as the power point is generated.   Now
if a user opens the power point and wants to re-order the position of the
slides, the page number will not re-order.   They want the page number to
re-order.

Hope you can help !!1

Gary

> Gary,
> David is correct. If you are already running PPT from Access VBA code
[quoted text clipped - 23 lines]
> >
> >Gary
Brian Reilly, MVP - 21 Nov 2007 18:55 GMT
Gary,

Not sure you want to run this from, but you can get this code from the
Macro Recorder and decide how to deal with this. I suppose you'd want
to tie it to the Presentation.Save event or something like that.

   If ActivePresentation.HasTitleMaster Then
       With ActivePresentation.TitleMaster.HeadersFooters
           .SlideNumber.Visible = msoTrue
       End With
   End If
   With ActivePresentation.SlideMaster.HeadersFooters
           .SlideNumber.Visible = msoTrue
   End With
   With ActivePresentation.Slides.Range.HeadersFooters
       .SlideNumber.Visible = msoTrue
   End With

Actually, you shouldn't have to tie it to any event, just run it from
inside your Access code when creating the presentation. Seems to work
here.

Brian Reilly, MVP

>I need the ability for users who open Power Point and reorder the slides.  
>Currently, I do generate slide number as the power point is generated.   Now
[quoted text clipped - 33 lines]
>> >
>> >Gary
Brian Reilly, MVP - 21 Nov 2007 19:09 GMT
Gary,
I just tested this and this is better code.
You can figure out how to incorporate it into your existing Access
code I should think.

Option Explicit

Sub add_auto_page_numbering()
'By Brian Reilly, MVP

   If ActivePresentation.HasTitleMaster Then
       With ActivePresentation.TitleMaster.HeadersFooters
           .SlideNumber.Visible = msoTrue
       End With
   End If
   With ActivePresentation.SlideMaster.HeadersFooters
           .SlideNumber.Visible = msoTrue
   End With

End Sub

Brian Reilly, MVP

>I need the ability for users who open Power Point and reorder the slides.  
>Currently, I do generate slide number as the power point is generated.   Now
[quoted text clipped - 33 lines]
>> >
>> >Gary
Gary - 21 Nov 2007 20:05 GMT
Thank You.   It looks very similiar to something that I did a macro recorder
on.

I just have a few question for my understanding.

1)   I could put this in my Access VBA Code, but does this need to be in the
point point file inorder for it to work correctly???  Like when a person
opens up a PPT file, and move slide 3 to the top.   Then the old 3 will not
be page 1.   When it do that even if the code was generated in Access???    
Or is the secret to it is allowing .SlideNumber to be visible in PPT that
does it all for me????

2)   Do you think I can place the SlideNumber at a differerent location by
using VBA Code to indicate the location to place a .text and have the .text
set to the .SlideNumber???

Thank You Very Much

Gary

> Gary,
> I just tested this and this is better code.
[quoted text clipped - 56 lines]
> >> >
> >> >Gary
John Wilson - 22 Nov 2007 14:35 GMT
Slide numbers will update when slides are moved. It doesn't depend on how
they were added.

You can add a text box with a slide number to the master with vba

This adds a box at 10,10 width 40 and height 20

Sub slidnum()
Dim oshp As Shape
With ActivePresentation.SlideMaster.Shapes
Set oshp = .AddTextbox(msoTextOrientationHorizontal, 10, 10, 40, 20)
oshp.TextFrame.TextRange.InsertSlideNumber
End With
ActivePresentation.SlideMaster.HeadersFooters.SlideNumber.Visible = True
Set oshp = Nothing
End Sub
Signature

Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk

> Thank You.   It looks very similiar to something that I did a macro recorder
> on.
[quoted text clipped - 76 lines]
> > >> >
> > >> >Gary
Steve Rindsberg - 22 Nov 2007 17:03 GMT
> 1)   I could put this in my Access VBA Code, but does this need to be in the
> point point file inorder for it to work correctly???  Like when a person
> opens up a PPT file, and move slide 3 to the top.   Then the old 3 will not
> be page 1.   When it do that even if the code was generated in Access???    
> Or is the secret to it is allowing .SlideNumber to be visible in PPT that
> does it all for me????

If you use slidenumber placeholders, they update themselves automatically within PPT
with no further code needed.  (see John's example code)

If you create your own slide numbers by adding text, then they're "dumb" text ... they
won't update, so you'd need to go to uncommon lengths to get things to work in PPT
when users rearrange slides.  Don't go there unless you really Really REALLY need to.

> 2)   Do you think I can place the SlideNumber at a differerent location by
> using VBA Code to indicate the location to place a .text and have the .text
> set to the .SlideNumber???

Again, see John's code for inserting the slidenumber "placeholder" ... but yep, you
can change the .Left, .Top and other coordinates of the shape that contains the slide
number.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Brian Reilly, MVP - 24 Nov 2007 11:48 GMT
Gary,

As John and Steve have pointed out, once you set the SlideNumber
Placeholder it is a live update in PPT when user changes order. I was
just suggesting that since you are creating original file from code in
Access that you turn on the SlideNumber placeholder in PPT from that
code.

Brian Reilly, MVP

>Thank You.   It looks very similiar to something that I did a macro recorder
>on.
[quoted text clipped - 76 lines]
>> >> >
>> >> >Gary
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.