現在のワークシートをコピーして空白の新しいワークブックに貼り付け、いくつかのセル (変数に格納されている) の値に応じて保存するコードがあります。
具体的には、サイト、クライアント、訪問日です。
サイトとクライアントではすべて正常に動作しますが、保存するファイル名に日付変数を含めると、エラーがスローされます: ランタイム エラー 76 - パスが見つかりません。
ヘルプ/アドバイスをいただければ幸いです。
Sub Pastefile()
Dim client As String
Dim site As String
Dim visitdate As String
client = Range("B3").Value
site = Range("B23").Value
screeningdate = Range("B7").Value
Dim SrceFile
Dim DestFile
SrceFile = "C:\2013 Recieved Schedules\schedule template.xlsx"
DestFile = "C:\2013 Recieved Schedules" & "\" & client & " " & site & " " & visitdate & ".xlsx"
FileCopy SrceFile, DestFile
ActiveWindow.SmallScroll Down:=-12
Range("A1:I37").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-30
Workbooks.Open Filename:= _
"C:\Schedules\2013 Recieved Schedules" & "\" & client & " " & site & " " & visitdate & ".xlsx", UpdateLinks:= _
0
Range("A1:I37").PasteSpecial Paste:=xlPasteValues
Range("C6").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
End Sub