• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Save Excel to NetworkDrive - Please Help

jansjane

Member
Code:
Option Explicit
Private Sub Workbook_Open()
  UserForm1.Show
  Application.Caption = "Microsoft Excel AutoBackup"
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim MyFilePath$, Extension$

MyFilePath = MyPCpath("MyDocuments")
    Extension = Left(ThisWorkbook.Name, Len _
    (ThisWorkbook.Name) - 4) & " Backup"

    On Error Resume Next '<< folder exists
    MkDir MyFilePath & Extension '<< create folder
    'save current version of this book in the folder
    ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & _
    Extension & "\" & Extension & _
    (Format(Now, " mmm d yyyy, hh.mm.ss AMPM")) & ".xls"

End Sub
Public Function MyPCpath$(Folder)
    MyPCpath = CreateObject("WScript.Shell").SpecialFolders _
    (Folder) & Application.PathSeparator
End Function
Hello VBA masters, I have the code above to allow me when I click on "Save", it will automatically save a backup file to my local drive (MyDocuments). I am wondering, how to to save it a network shared drive? I tried to play around, not success, and wish someone here is able to point me how.

I don't know whole a lot about VBA, I will greatly appreciate your help.

the network drive is T:/AB or \\new.ca\AB
__________________________________________________________________
Mod edit : thread moved to appropriate forum !
 
Last edited:
Back
Top