Saturday, April 24, 2010

How to Save Powerpoint Presentation with Password using VBA

How to Specify the Password in SaveAs option in PowerPoint VBA

Unlike SaveAs in Word/Excel, which takes the Password as part of the argument, Powerpoint SaveAs function doesn't specify it.

Here is a way to do it through VBA

Sub Save_Presentation_With_Password()

Dim oPS As PowerPoint.Presentation
Dim sTempPath As String

Set oPS = Presentations.Add
oPS.Slides.Add 1, ppLayoutTitle

' ----------------------------
' Coded by Shasur for VBADUD.Blogspot.com
' ----------------------------

sTempPath = Environ("Temp") & "\"

oPS.Password = "PPTPWD"


oPS.SaveAs FileName:=sTempPath & "PPTSample1.pptx", FileFormat:=ppSaveAsDefault
oPS.Close


End Sub 
 

See also


Run Excel Macro from Powerpoint VBA

Save Powerpoint Slides as Images using VBA

Add Controls Popup Menu using Powerpoint VBA

VBA - Creating PowerPoint Presentation

 

 

 

 

How to Convert Automatic Hyphens to Manual Hyphens using Word VBA

Word does automatic hyphenation at the end of line when the AutomaticHyphenation feature is turned on

ActiveDocument.AutoHyphenation = True 

For example, in the pic below, the word has hyphenated non-breaking automatically



You can test it by try selecting the Hyphen (which is not there physically)

The following code converts all automatic hyphens to manual ones

ActiveDocument.ConvertAutoHyphens

Friday, April 23, 2010

Unprotect and Protect Sheet using VBA code

How to write to protected Excel file using VBA

Here is a sample to unprotect a sheet and write some values and then protect the sheet again


Sub Unprotect_And_ThenProtect()
    
    ActiveSheet.Unprotect
    Range("A2").Value = Now()
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub

Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.