|
Sub Add_BookNum()
Dim WB As Workbook
Dim MyF As String, SvF As String, NewFN As String
Dim Fnum As Integer
MyF = Application _
.GetOpenFilename("Excelブック(*.xls),*.xls")
If MyF = "False" Then Exit Sub
Set WB = Workbooks.Open(MyF)
'ここにマクロ実行ブック(ブックA)から、開いたブック(WB)への
'データ転記処理コードを入れる。
SvF = Replace(ThisWorkbook.Path, "フォルダA", "フォルダB")
With Application.FileSearch
.LookIn = SvF
.FileType = msoFileTypeExcelWorkbooks
Fnum = .FoundFiles.Count + 1
End With
NewFN = SvF & "\" & Format(Date, "yymmdd") & "_" & _
Left$(Dir(MyF), Len(Dir(MyF)) - 4) & "_" & Fnum & ".xls"
WB.Close True, NewFN: Set WB = Nothing
End Sub
てな感じでしょーか。
|
|