Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 989
Default Saving or Linking a workbook on two drives

I have a workbook saved on my local hard drive, but i want to save or link it
to a workbook on the network drive. Of course the files are the same format,
basically so other can access without having to 'save' twice?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Saving or Linking a workbook on two drives

I do something like that with my Personal.xls workbook. Not to share with
others, just for peace of mind in case my laptop gets nicked. It means I
don't have to remember to save it once never mind twice. It also means
writing code, and since you are in the General Questions section, I don't
know how familiar you are with that, but here goes. I've modified my code
slightly but it should work for you if you change the constants to point at
drive paths relevant to you.

In the code page for the 'ThisWorkbook' object put:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Archive_PWB
End Sub

The rest can go in any module in the same workbook, but for simplicity you
could put it in the same place (but if you do, the constants must go to the
top of the sheet):

Const Localpath As String = "C:\mySharedFiles\"
Const Networkpath As String = "\\myNetworkDrive\myFolder\"

Public Sub Archive_PWB()
If Not ActiveWorkbook.Saved Then
'Save it locally (if new) or overwrite existing (if not) before ...
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Localpath & ActiveWorkbook.Name
Application.DisplayAlerts = True
'... doing the archive
Copy_to_Network_Drive
End If
Exit Sub
End Sub
Private Sub Copy_to_Network_Drive()
Dim Answer As String
Dim fsObject As Object
On Error GoTo eCode
Set fsObject = CreateObject("Scripting.FileSystemObject")
fsObject.copyfile _
Localpath & ActiveWorkbook.Name, _
Networkpath & ActiveWorkbook.Name, _
True 'overwrite
Set fsObject = Nothing
Exit Sub
eCode:
If Err.Number = 76 Then
'Network Drive unavailable.
Answer = InputBox("Network drive unavailable continue without
saving?" & vbCrLf & _
"If No, make it available before continuing.", _
"Copy_to_Network_Drive", "Y")
If UCase(Answer) = "Y" Then
Resume Next
Else
Resume
End If
Else
MsgBox "Unexpected error: " & Err.Number & " - " & Err.Description,
, _
"Copy_to_Network_Drive"
End If
End Sub

"Mark" wrote:

I have a workbook saved on my local hard drive, but i want to save or link it
to a workbook on the network drive. Of course the files are the same format,
basically so other can access without having to 'save' twice?

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
Modified date issues when saving to mapped drives using Excel 2007 Liverpool Excel Discussion (Misc queries) 0 June 4th 08 06:08 PM
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Saving Large .xls file to external drives iumike2004 Excel Discussion (Misc queries) 2 March 10th 06 05:01 PM
Auto Update Linking and Saving Chewy Excel Discussion (Misc queries) 3 May 13th 05 08:41 PM
saving files with mapped drives Derek Excel Discussion (Misc queries) 0 May 9th 05 07:49 PM


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