Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    strPath = ThisWorkbook.Path & "\"
    Set v1 = ThisWorkbook
    Set w1 = v1.Worksheets("Summary")
    strDate = w1.Range("B2")

    'How can I save v1 in strPath named strDate formatted to dd.mm.yy ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    ...
    strDate = Format(w1.Range("B2"), "dd.mm.yy")
    v1.SaveAs strPath & strDate & ".xls"

    But I'd recommend using a different date format. Although points are allowed in file names, they can be confusing since the point is also used to separate the file name and extension. I'd use a format such as yyyymmdd - this makes it easy to sort the files.

  3. #3
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans, for both the help and advice. There are occasions where the file will already exist, so how can I automatically overwrite the existing file without being prompted?

    I should know this, but I can't find reference to it anywhere.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Insert a line

    Application.DisplayAlerts = False

    above the line with SaveAs, and

    Application.DisplayAlerts = True

    below it. See DisplayAlerts Property.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Yuck - the Lounge software seems to "correct" upper case use in a sentence and within a word automatically, without warning. The "a" in alert in Displayalert should be an A.

Posting Permissions

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