2013-07-09 38 views
0

我有下面的VBA我已經寫的,需要一點幫助,最後一位VBA把日期和時間輸出文本文件

Sub testlist() 
Open "C:\Users\gaum\Desktop\Work\NCL\testlist.lst" For Output As #1 
For NR = 1 To Selection.Rows.Count 
For NC = 1 To Selection.Columns.Count 
ExpData = Selection.Cells(NR, NC).Value 
If IsNumeric(ExpData) Then ExpData = Val(ExpData) 
If IsEmpty(Selection.Cells(NR, NC)) Then ExpData = "" 
If NC <> NumCols Then 
If Not ExpData = "FilePath" Then Print #1, ExpData 
End If 
Next NC 
Next NR 
Close #1 
End Sub 

它本質上需要一個突出顯示的列,併產生一個純文本逐行顯示內容的文件。

我需要幫助的是輸出文件的標題。我如何添加宏的運行日期和時間?所以輸出是testlist_date_time.lst

回答

3
Open "C:\Users\gaum\Desktop\Work\NCL\" & Format(Now(), "_yyyy-mm-dd_hh-mm") & ".lst" For Output As #1 
    ... 
Close #1 
+0

該作品非常感謝 – manish449

相關問題