Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Modified date issues when saving to mapped drives using Excel 2007 | Excel Discussion (Misc queries) | |||
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook | Excel Discussion (Misc queries) | |||
Saving Large .xls file to external drives | Excel Discussion (Misc queries) | |||
Auto Update Linking and Saving | Excel Discussion (Misc queries) | |||
saving files with mapped drives | Excel Discussion (Misc queries) |