Help In Inserting Slide Number Using VBA Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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

--
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/
 
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 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,

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
 
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
 
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
 
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
--
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
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.
 
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
 
Gary,

I have one request. I have a powerpoint presentacion which goes a slide 1,2,3,x, but also I have 2 picture in each slice and i want a code that count each picture with a textbox below.

Ex:

Slide 50


picture ((50*2)-1) picture (50*2)

Thanks in advance
 
Is there a point to this post? What does it mean

"Re: Gary, As John and Steve have pointed out, once you set the"

Set the WHAT?

Titles of posts are short and to the point; CONTENT of the post is in the body. Attempts
to put content in the title are doomed.
joe

Gary,

I have one request. I have a powerpoint presentacion which goes a slide 1,2,3,x, but also I have 2 picture in each slice and i want a code that count each picture with a textbox below.

Ex:

Slide 50


picture ((50*2)-1) picture (50*2)

Thanks in advance
Joseph M. Newcomer [MVP]
email: (e-mail address removed)
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 
Back
Top