Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Saving to network - trap error

I have a weekly report that when I close it, it saves to the C: drive and
then to the network drive, and pops up some msg boxes telling me they have
saved. Here's a snippet:

Sub Workbook_BeforeClose(Cancel As Boolean)
.....
sPath = "C:\My Documents\Saddle Creek\WeeklySalesRpt\"
sPath2 = "G:\Jason\Weekly Sales Report\"
wbname = Sheets(1).Name & " " & Sheets(1).[A2].Value
wb.SaveAs sPath & wbname & ".xls"
MsgBox "File saved to C drive!"
wb.SaveAs sPath2 & wbname & ".xls"
MsgBox "File saved to G drive!"
......
End Sub

I'd like to improve the code and have Excel tell me if the file does not
save to the G: drive for whatever reason, then continue with macro (closing
workbook).

Thanks!
Jason
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Saving to network - trap error

As far as I know excel always saves or it will tell you (read only access to
a network folder...etc) ... check to make sure you don't have
application.enableevents = false in your code or the error message will not
pop up.

"Jason Morin" wrote:

I have a weekly report that when I close it, it saves to the C: drive and
then to the network drive, and pops up some msg boxes telling me they have
saved. Here's a snippet:

Sub Workbook_BeforeClose(Cancel As Boolean)
....
sPath = "C:\My Documents\Saddle Creek\WeeklySalesRpt\"
sPath2 = "G:\Jason\Weekly Sales Report\"
wbname = Sheets(1).Name & " " & Sheets(1).[A2].Value
wb.SaveAs sPath & wbname & ".xls"
MsgBox "File saved to C drive!"
wb.SaveAs sPath2 & wbname & ".xls"
MsgBox "File saved to G drive!"
.....
End Sub

I'd like to improve the code and have Excel tell me if the file does not
save to the G: drive for whatever reason, then continue with macro (closing
workbook).

Thanks!
Jason

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
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Saving error on network ryanlcs Excel Discussion (Misc queries) 1 December 23rd 05 01:08 PM
Trap New File name before saving BAC Excel Programming 1 June 30th 05 03:11 PM
Read-only error saving to network Will B Excel Discussion (Misc queries) 0 May 2nd 05 05:59 PM


All times are GMT +1. The time now is 12:24 PM.

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"