+ Reply to Thread
Results 1 to 2 of 2

Macro which create a copy of file during saving

  1. #1
    Registered User
    Join Date
    12-10-2010
    Location
    Wroclaw
    MS-Off Ver
    Excel 2003
    Posts
    1

    Macro which create a copy of file during saving

    Hello everyone,

    I have small issue which can not solve myself. I would like to have macro which create a copy of existing Excel file during saving. The name of new file should looks like this: hh.mm.ss_dd.mm,yyyy, where hh is creation hour, mm means minute and so one. I have created such a macro but someting is wrong with them.
    I will appreciate if you could correct below code.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)

    Dim Nazwa As String
    Dim Sciezka As String

    Sciezka = "D:\"
    Nazwa = Format(Now(), "hh.mm.ss_dd.mm.yy") & ".xls"

    ThisWorkbook.Save
    ActiveWorkbook.SaveAs FileName:=Sciezka & Nazwa

    End Sub

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro which create a copy of file during saving

    Please Login or Register  to view this content.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1