使文件名包含日期(VBA)

时间:2012-04-12 12:07:40

标签: vba excel-vba excel

我想将文件保存在目录中,文件名应采用以下格式:

iTerm Metrics Report Apr 12

即。根文件名称“iTerm指标报告”,然后是今天的日期,格式为三个字母的月份,然后是月份的日期。

如何制作这样的文件名?

1 个答案:

答案 0 :(得分:4)

  
    
      

sFile =“iTerm指标报告”& “”&格式(日期)& “.xls”ActiveWorkbook.SaveAs文件名:=“C:\ Documents and Settings \ 706849 \ My Documents \ Metric Report \”& sFile - Arul Servin 5秒前

    
  

这是你在尝试的吗?

sFile = "iTerm metrics Report " & Format(Date,"mmm yy") & ".xls"

<强>后续

  
    
      

谢谢...但我正在尝试约会(4月12日)12是一个不是一年的日期...请相应地建议我...谢谢 - Arul Servin 55秒前

    
  

在这种情况下,将代码更改为

sFile = "iTerm metrics Report " & Format(Date,"mmm dd") & ".xls"
相关问题