![]() |
Error Trapping saving file to network drive
I have a simple save routine which saves the file to my own c drive and then
a copy to a network drive. How can I run the sproceedure and trap the error if the pc is not connected to the network. Also would it be possible to trap another error - say if the file had been opened by someone using the network drive copy, to ignore the second part of the routine too and perhaps send a message back to the user that it has been saved to the local drive but not the network. Sub SaveOptions() ' ' SaveOptions Macro ' Macro recorded 25/09/2006 by Gary Mallin 'Save to own hard-drive ChDir "C:\Documents and Settings\malling\My Documents\Gary's Documents" ActiveWorkbook.SaveAs Filename:= _ "C:\Documents and Settings\malling\My Documents\Gary's Documents\TOIL 2006-2007 Gary.xls" _ , FileFormat:=xlNormal, Password:="gazzaflexi", WriteResPassword:= _ "", ReadOnlyRecommended:=False, CreateBackup:=False 'Save to Network Drive ChDir "Z:\man ac\Preston06-07\TOIL" ActiveWorkbook.SaveAs Filename:= _ "Z:\man ac\Preston06-07\TOIL\TOIL 2006-2007 Gary.xls", FileFormat:=xlNormal, _ Password:="gazzaflexi", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub As always help from this forum greatly appreciated Gaz |
Error Trapping saving file to network drive
Sub SaveOptions()
' ' SaveOptions Macro ' Macro recorded 25/09/2006 by Gary Mallin 'Save to own hard-drive ChDir "C:\Documents and Settings\malling\My Documents\Gary's Documents" ActiveWorkbook.SaveAs Filename:= _ "C:\Documents and Settings\malling\My Documents\Gary's Documents\TOIL 2006-2007 Gary.xls" _ , FileFormat:=xlNormal, Password:="gazzaflexi", WriteResPassword:= _ "", ReadOnlyRecommended:=False, CreateBackup:=False 'Save to Network Drive on error Resume Next ChDir "Z:\man ac\Preston06-07\TOIL" ActiveWorkbook.SaveAs Filename:= _ "Z:\man ac\Preston06-07\TOIL\TOIL 2006-2007 Gary.xls", FileFormat:=xlNormal, _ Password:="gazzaflexi", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False On Error goto 0 if Left(Activeworkbook.Path,1) < "Z" then msgbox "Only saved to local drive" end if End Sub -- Regards, Tom Ogilvy "Gazza" <mallin"nospam" wrote: I have a simple save routine which saves the file to my own c drive and then a copy to a network drive. How can I run the sproceedure and trap the error if the pc is not connected to the network. Also would it be possible to trap another error - say if the file had been opened by someone using the network drive copy, to ignore the second part of the routine too and perhaps send a message back to the user that it has been saved to the local drive but not the network. Sub SaveOptions() ' ' SaveOptions Macro ' Macro recorded 25/09/2006 by Gary Mallin 'Save to own hard-drive ChDir "C:\Documents and Settings\malling\My Documents\Gary's Documents" ActiveWorkbook.SaveAs Filename:= _ "C:\Documents and Settings\malling\My Documents\Gary's Documents\TOIL 2006-2007 Gary.xls" _ , FileFormat:=xlNormal, Password:="gazzaflexi", WriteResPassword:= _ "", ReadOnlyRecommended:=False, CreateBackup:=False 'Save to Network Drive ChDir "Z:\man ac\Preston06-07\TOIL" ActiveWorkbook.SaveAs Filename:= _ "Z:\man ac\Preston06-07\TOIL\TOIL 2006-2007 Gary.xls", FileFormat:=xlNormal, _ Password:="gazzaflexi", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub As always help from this forum greatly appreciated Gaz |
Error Trapping saving file to network drive
Thanks Tom
kind regards Gary "Tom Ogilvy" wrote in message ... Sub SaveOptions() ' ' SaveOptions Macro ' Macro recorded 25/09/2006 by Gary Mallin 'Save to own hard-drive ChDir "C:\Documents and Settings\malling\My Documents\Gary's Documents" ActiveWorkbook.SaveAs Filename:= _ "C:\Documents and Settings\malling\My Documents\Gary's Documents\TOIL 2006-2007 Gary.xls" _ , FileFormat:=xlNormal, Password:="gazzaflexi", WriteResPassword:= _ "", ReadOnlyRecommended:=False, CreateBackup:=False 'Save to Network Drive on error Resume Next ChDir "Z:\man ac\Preston06-07\TOIL" ActiveWorkbook.SaveAs Filename:= _ "Z:\man ac\Preston06-07\TOIL\TOIL 2006-2007 Gary.xls", FileFormat:=xlNormal, _ Password:="gazzaflexi", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False On Error goto 0 if Left(Activeworkbook.Path,1) < "Z" then msgbox "Only saved to local drive" end if End Sub -- Regards, Tom Ogilvy "Gazza" <mallin"nospam" wrote: I have a simple save routine which saves the file to my own c drive and then a copy to a network drive. How can I run the sproceedure and trap the error if the pc is not connected to the network. Also would it be possible to trap another error - say if the file had been opened by someone using the network drive copy, to ignore the second part of the routine too and perhaps send a message back to the user that it has been saved to the local drive but not the network. Sub SaveOptions() ' ' SaveOptions Macro ' Macro recorded 25/09/2006 by Gary Mallin 'Save to own hard-drive ChDir "C:\Documents and Settings\malling\My Documents\Gary's Documents" ActiveWorkbook.SaveAs Filename:= _ "C:\Documents and Settings\malling\My Documents\Gary's Documents\TOIL 2006-2007 Gary.xls" _ , FileFormat:=xlNormal, Password:="gazzaflexi", WriteResPassword:= _ "", ReadOnlyRecommended:=False, CreateBackup:=False 'Save to Network Drive ChDir "Z:\man ac\Preston06-07\TOIL" ActiveWorkbook.SaveAs Filename:= _ "Z:\man ac\Preston06-07\TOIL\TOIL 2006-2007 Gary.xls", FileFormat:=xlNormal, _ Password:="gazzaflexi", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub As always help from this forum greatly appreciated Gaz |
All times are GMT +1. The time now is 08:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com