code to rename a file

  • Thread starter Thread starter EllaMentary
  • Start date Start date
E

EllaMentary

I'm working on creating a redacted (expunged) version of powerpoint
presentations for distribution outside our organization. I have a
macro to strip out notes and changing embedded charts to pics (so no-
one can see the data behind).

However, I need to add a prompts the user into File>Save As and
changes a filename and/or extension. For example.

test.ppt to r-test.ppt
or
test.pps to test.pps

This is to ensure the user doesn't accidently overwrite the original
file.

Any advice is greatly appreciated. I can post the finalized code if
anyone is interested.
 
Do you really need to hand them a dialog box?  Could you just save the file
back to the original folder then tell them what you've done?

Dim sPath As String
Dim sFileName As String

With ActivePresentation
   sPath = .Path & "\"
   sFileName = "r-" & .Name
   .SaveAs FileName:=sPath & sFileName, fileformat:=ppSaveAsDefault
End With

MsgBox "Whacked, Smacked, Redacted and Saved to:" & vbcrlf _
       & sPath & sFileName

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

Thank you Steve for your help. It worked beautifully.
 
Maybe include something like this:
Set opres = ActivePresentation
opres.SaveAs opres.Path & "\r-" & opres.Name
--

john ATSIGN PPTAlchemy.co.uk
Custom vba coding and PPT Makeovers
Free PPT Hints, Tips and Tutorialshttp://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html









- Show quoted text -

Thanks John. The code worked. The minor caveat was when I closed the
file and tried to rerun it it gave me an error message that the file
was open (even if I deleted it).
 
Back
Top