LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Force a Readonly Workbook to save to a different folder

Thanks Dave, that works a treat
Charlotte

"Dave Peterson" wrote:

Maybe you can disable any saving and just provide a macro to save to the
location of your choice.

This all depends on macros being enabled and events being enabled.

Behind the ThisWorkbook module:
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "Not Saved!!!" & vbLf & "Please use the button to save!"
End Sub

And provide them some way of saving the workbook (a button from the Forms
toolbar on the worksheet???).

In fact, some of "forms" I've worked with use a cell in that worksheet as a
placeholder for the filename.

Maybe you can do something like that (or modify this to get the filename some
other way):

Behind a general module:

Option Explicit
Sub SpecialSave()
Dim myFileName As String
Dim myPath As String
Dim TestStr As String
Dim resp As Long
Dim myErrNumber As Long
Dim myErrDesc As String

myPath = "C:\temp\"
myFileName = ActiveSheet.Range("a1").Value

'some minor checks
If Trim(myFileName) = "" Then
MsgBox "Please put something in the filename cell!"
Exit Sub
End If
If InStr(1, myFileName, "\", vbTextCompare) 0 _
Or InStr(1, myFileName, "/", vbTextCompare) 0 Then
MsgBox "Please fix the filename cell!"
Exit Sub
End If

If LCase(Right(myFileName, 4)) = ".xls" Then
'ok
Else
myFileName = myFileName & ".xls"
End If

myFileName = myPath & myFileName

'check for existing files with that name
TestStr = ""
On Error Resume Next
TestStr = Dir(myFileName)
On Error GoTo 0

If TestStr = "" Then
'no existing files with that name
Else
resp = MsgBox(Prompt:="Overwrite existing file?", Buttons:=vbYesNo)
If resp = vbNo Then
MsgBox "File not saved!"
Exit Sub
End If
End If

'try to save it
On Error Resume Next
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.SaveAs FileName:=myFileName, FileFormat:=xlWorkbookNormal
myErrNumber = Err.Number
myErrDesc = Err.Description
Err.Clear
Application.DisplayAlerts = True
Application.EnableEvents = True
On Error GoTo 0

If myErrNumber = 0 Then
MsgBox "File saved to: " & ThisWorkbook.FullName
Else
MsgBox "File Not Saved" & vbLf & myErrNumber & vbLf & myErrDesc
End If

End Sub


Charlotte Howard wrote:

Hi,

I have created 2 workbooks that are password protected so that end users can
only open a read-only copy. They will need to save a copy for themselves,
which I want them to do in a particular folder on the network.

The Workbook templates are in /finance/valuations, and the workbooks should
be saved in /finance/WIP

any help appreciated,
Charlotte


--

Dave Peterson

 
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
save to folder based on cell value Steve Excel Discussion (Misc queries) 1 June 15th 06 07:54 PM
open and save an entire folder SusanWS Excel Discussion (Misc queries) 1 June 15th 06 03:56 PM
Cannot save excel files to a folder on a network Robbie Excel Discussion (Misc queries) 1 June 9th 06 07:26 AM
How can force enable macros to be able to open my workbook? kcdonaldson Excel Discussion (Misc queries) 3 December 5th 05 06:16 PM
macro save a workbook whilst increasing file no shrek Excel Worksheet Functions 0 November 10th 05 02:40 PM


All times are GMT +1. The time now is 12:21 AM.

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

About Us

"It's about Microsoft Excel"