Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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





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
Saving Excel File to a Network Drive Jason Excel Discussion (Misc queries) 2 March 2nd 10 05:16 PM
Problem saving to network drive Peter Rooney Excel Programming 11 November 30th 05 01:10 PM
Sporadic errors when saving to network drive Peter Rooney Excel Programming 2 November 28th 05 11:16 AM
Excel 2003 - problem saving to a mapped network drive Chris Excel Discussion (Misc queries) 1 October 17th 05 05:57 PM
Saving to network drive gives unwanted copy or overwrite message Bill Excel Discussion (Misc queries) 2 July 29th 05 02:25 AM


All times are GMT +1. The time now is 07:13 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"