Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert file path with a macro in Powerpoint 6

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
Well just as the subject says really. I want a macro that will insert the path of the current file as a string of text at the bottom of each slide in the presentation. I don't know where to start!

Thanks a lot to anyone who can help with this.
 

Sub tranpkp()

End Sub
'
' Macro recorded 10/21/2002 by tranpkp
'

If ActivePresentation.HasTitleMaster Then
With ActivePresentation.TitleMaster.HeadersFooters
With .DateAndTime
.Format = ppDateTimeMdyy
.Text = ""
.UseFormat = msoFalse
.Visible = msoTrue
End With
With .Footer
.Text ="Application.ActivePresentation.Path"
.Visible = msoTrue
End With
.SlideNumber.Visible = msoFalse
End With
End If

Tranpkp
************************************
- Let me know if this helped/worked!
 
That's fantastic, thanks a lot for your help. I'll let you know how it goes!
 
Hmm can't seem to get it working, I had to correct what you posted (just the End Sub was in the wrong place). Now when I run it it runs without complaining, but I don't actually get any footers added to the slides. I think it's something to do with the HasTitleMaster conditional. Any ideas?

All I did was start Powerpoint, create a new presentation, add the macro in Visual Basic and then run it, am I doing something wrong? (I'm inexperienced with writing Powerpoint Macros).

Thanks again.
 
I stole it from Tran, but edited it so it should work:

Sub AddFeet()

With ActivePresentation.SlideMaster.HeadersFooters
With .DateAndTime
.Format = ppDateTimeMdyy
.Text = ""
.UseFormat = msoFalse
.Visible = msoTrue
End With
With .Footer
.Text = "Application.ActivePresentation.Path"
.Visible = msoTrue
End With
.SlideNumber.Visible = msoFalse
End With
End Sub


Basically, his code put it on Title Masters, which aren't used often. The MASTER is what was needed. Anne Troy
 
FYI: the code relies on the fact that it has to find the file (you opened a new one, I assume you never saved it), if you don't save it, technically the file path still doesn't exist. Save it first , the code should then wrok:

sub tranpkp()
Dim test As String
test = Application.ActivePresentation.Path

ActivePresentation.SlideMaster.HeadersFooters.Footer.Text = "" & Application.ActivePresentation.Path

end sub
Tranpkp
************************************
- Let me know if this helped/worked!
Please remember to give helpful posts the stars they deserve!
This facilitates the threads / posts for others! :)
 
Thanks for the help Anne! I felt bad, cause I thought I actually didn't debug but I really did. I forgot that I must have saved the presentation first. also the quotes won't work w/ Anne's code, plus I truncated mine. Sorry first code I ever wrote for Pwrpt. I don't even know what all that extra code was, I just used the record option to get me started. The beforementioned code works w/ Ofc XP.

HTH,
Tranpkp
************************************
- Let me know if this helped/worked!
Please remember to give helpful posts the stars they deserve!
This facilitates the threads / posts for others! :)
 
You both deserve a star. Thanks for the help.

Which of these would it be best for me to use?

1)
Code:
Sub path_macro()
'
' Macro created 21/10/2002 by miraclemaker
'
        
        With ActivePresentation.SlideMaster.HeadersFooters
            With .DateAndTime
                .Format = ppDateTimeMdyy
                .Text = ""
                .UseFormat = msoFalse
                .Visible = msoTrue
            End With
            With .Footer
                .Text = Application.ActivePresentation.Path
                .Visible = msoTrue
            End With
            .SlideNumber.Visible = msoFalse
        End With
    
End Sub

2)
Code:
Sub path_macro()
'
' Macro created 21/10/2002 by miraclemaker
'

Dim test As String
test = Application.ActivePresentation.Path

ActivePresentation.SlideMaster.HeadersFooters.Footer.Text = "" & Application.ActivePresentation.Path
   
End Sub

 
I would think the less constraints you put the better. The second is what I coded freehand, the first what stemmed from 'record macro'. I experience in the past is that either will presumably work fine, but the code is better as concise as possible and elimination of anything un-needed/intended should be done. As well some of the extras won't be backward compatible. Tranpkp
************************************
- Let me know if this helped/worked!
Please remember to give helpful posts the stars they deserve!
This facilitates the threads / posts for others! :)
 
miraclemaker, just to be clear, you don't need the "" & application...etc, that was just during my debug process ( I couldn't understand why strings were in the footer but no path, then I realized that save thing) you can just put:

ActivePresentation.SlideMaster.HeadersFooters.Footer.Text = Application.ActivePresentation.Path

if you didn't figure that out already ;) Just to be clear months later and you don't remember what's going on! Tranpkp
************************************
- Let me know if this helped/worked!
Please remember to give helpful posts the stars they deserve!
This facilitates the threads / posts for others! :)
 
That's great I took out the test String bit as well as that wasn't used.

I don't know if this is possible, but can I have it so the Macro is run every time the document is saved? Or alternatively through some other means have the path in the footer always kept up to date.
 
...Or even better run the macro every time the document is opened?
 
This took me FOREVER VBA for Pwrpt. Pwrpt does NOT have built in events enabled. It does support it. You HAVE to write it. This STINKS. I am still uncertain exactly how it all works.
I finally got a solution working, involves an add-in (I never even used these before) basically to establish the ability to use some events. You have to put it somewhere and select it to be loaded by Pwrpt. Then whenever you save a file it should work (adds the path to the footer.)
the only problem is on a new presentation it seems to want to save it 2x before it will work? if you want the addin bump your email and i'll send it. Tranpkp
************************************
- Let me know if this helped/worked!
Please remember to give helpful posts the stars they deserve!
This facilitates navigating through the threads / posts!
 
That's brilliant. Thanks Tranpkp. my email is: miraclemaker@totalise.nospam.co.uk

(remove the nospam)
 
i would very much like a look as well.

Thanks

thom.moon@btopenworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top