Consulting

Results 1 to 3 of 3

Thread: Macro to save a readonly copy of file with todays date

  1. #1
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    3
    Location

    Macro to save a readonly copy of file with todays date

    Hey guys,

    Having a little trouble with this; I just want to save a read-only copy of a file in a different folder with todays date but for some reason I cant figure out whats wrong with this code, it saves the file name with "dt" and not the actual date? (help would be really appreciated!)

    Sub Readonly()
    ' SaveAsReadOnly Macro
    Dim dt As String
    dt = Format(Now, "yyyymmdd")
        ChDir "G:\Capital Markets\Tools\DS"
        ActiveWorkbook.SaveCopyAs Filename:= _
            "G:\Capital Markets\Tools\DS\Spreads & dt.xlsb"
    SetAttr "G:\Capital Markets\Tools\DS\Spreads & dt.xlsb", vbReadOnly
    End Sub

  2. #2
    try
    ActiveWorkbook.SaveCopyAs Filename:= _
    "G:\Capital Markets\Tools\DS\Spreads" & dt & ".xlsb"

  3. #3
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    3
    Location
    Awesome that did it! Thanks a bunch

Tags for this Thread

Posting Permissions

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