Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Save a File with a Password Q

Is it possible to save via Code a file with a password that resides is
a cell within the workbook?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Save a File with a Password Q

Hi,

Maybe something along these lines

Sub Save_Me()
MyPass = Sheets("Sheet1").Range("A1").Value
Fname = ActiveWorkbook.Name
ActiveWorkbook.SaveAs Filename:=Fname, Password:=MyPass
End Sub


Mike

"Seanie" wrote:

Is it possible to save via Code a file with a password that resides is
a cell within the workbook?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Save a File with a Password Q

this example may be a little more than you were looking for as includes a
test on Path to detrmine if file has been previousley saved - it also shows
how to include password from a range value.

Hope useful

Sub SaveBook()
Dim Passwrd As Range
Dim FName As Variant
Dim FPath As String

'change sheet name & range as required
Set Passwrd = Worksheets("Sheet1").Range("A1")

Application.DisplayAlerts = False

With ThisWorkbook

FName = .Name
FPath = .Path

If FPath < "" Then

.SaveAs Filename:=FName, Password:=Passwrd.Value

Else

FName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls")

If FName < False Then

.SaveAs Filename:=FName, Password:=Passwrd.Value

End If

End If

End With

Application.DisplayAlerts = True

End Sub


--
jb


"Seanie" wrote:

Is it possible to save via Code a file with a password that resides is
a cell within the workbook?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them LJ[_4_] Excel Programming 0 April 27th 06 03:18 AM
Save file without a password req Ctech[_28_] Excel Programming 4 November 1st 05 11:39 PM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM
Save protected file into unprotected file without password Paul Excel Programming 3 August 2nd 03 05:17 PM


All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"