EXCEL VBA 另存新檔的問題

Home Home
引用 | 編輯 jay927
2006-03-10 17:02
樓主
推文 x0
1.請問要怎樣讓運算完成的EXCEL報表直接自動另存新檔?
2 ..

訪客只能看到部份內容,免費 加入會員



獻花 x0
引用 | 編輯 circlemap
2006-03-10 17:44
1樓
  
Option Explicit
Const FolderPath As String = "C:\tmp\"


Sub eee()

Dim strDay As String
Dim strMonth As String
Dim strYear As String

strDay = Day(Now)
strMonth = Month(Now)
strYear = Year(Now)

If Val(strDay) < 10 Then
strDay = "0" & strDay
End If

If Val(strMonth) < 10 Then
strMonth = "0" & strMonth
End If

strYear = Right(strYear, 2)


Application.DisplayAlerts = False

ThisWorkbook.SaveAs (FolderPath & strDay & strMonth & strYear)

Application.DisplayAlerts = True

End Sub

稍微寫了一下   不過 你要有 C:\tmp\ 這個資料夾存在,或者你改
Const FolderPath As String = "C:\tmp\" 這一句成為你要的資料夾

獻花 x0
引用 | 編輯 jay927
2006-03-11 00:49
2樓
  
感謝大大!
存檔的部分完成了!
不過另外的問題又出現!
新存的檔案連巨集也一起存進去裡面!
能夠做到新存的檔案裡面只有資料,不把巨集也存進去嗎?

獻花 x0
引用 | 編輯 iwinblue
2009-04-23 18:51
3樓
  
請問依下這個地方哪裡有錯,我看不出來,請大家幫我依下,感恩
儲存的檔案,叫不出來
以下所以的條件
排序,再另存新檔

Option Explicit
Const FolderPath As String = "C:\tmp\"
Sub eee()

  Cells.Select
  Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("B2") _
    , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
    False, Orientation:=xlTopToBottom, SortMethod:=xlStroke, DataOption1:= _
    xlSortNormal, DataOption2:=xlSortNormal
  Range("H7").Select
  Columns("I:I").ColumnWidth = 11.75
  Columns("I:I").ColumnWidth = 14






Dim strYear As String
Dim strMonth As String
Dim strDay As String

strYear = Year(Now)
strMonth = Month(Now)
strDay = Day(Now)

strYear = Right(strYear, 2)

If Val(strMonth) < 10 Then
strMonth = "0" & strMonth
End If

If Val(strDay) < 10 Then
strDay = "0" & strDay
End If


Application.DisplayAlerts = False

ThisWorkbook.SaveAs (FolderPath & strYear & strMonth & strDay)

Application.DisplayAlerts = True

End Sub

獻花 x0
引用 | 編輯 lmz
2009-06-06 00:08
4樓
  
用巨集錄製如下
  Cells.Select
  Selection.Sort Key1:=Range("C2")、Order1:=xlAscending、Key2:=Range("B2") _
    、Order2:=xlAscending、Header:=xlYes、OrderCustom:=1、MatchCase:=False _
    、Orientation:=xlTopToBottom、SortMethod:=xlPinYin、DataOption1:= _
    xlSortNormal、DataOption2:=xlSortNormal
.
.
Columns("I:I").ColumnWidth = 11.75......此段可以刪除
Columns("I:I").ColumnWidth = 14

If Val(strMonth) < 10 Then
strMonth = "0" & strMonth
End If

可以改為

strMonth = WorksheetFunction.Text(strMonth, "00")

獻花 x0