您能告诉我如何修改以下代码,以便自动打开它吗?
Range("A1:AK1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A1").Select
Workbooks.Open Filename:= _
"Y:\DentalConsumables\Company\DMC\DMC - Planning & Materials\Build Plan DTW Reports\DataWHSreports\2015-03-26_DWHS_PEN EU Fixed.xlsx" _
, UpdateLinks:=0, Notify:=False
ActiveWindow.SmallScroll Down:=12
答案 0 :(得分:1)
如果只有日期部分发生变化,您可以尝试一下:
编辑1:关闭已打开的文件
Dim curDate As String, Fname As String
curDate = Format(Date, "yyyy-mm-dd") ' returns the current date in specified format
Dim wb As Workbook ' add a variable to pass your workbook object
Fname = "Y:\DentalConsumables\Company\DMC\DMC - Planning & Materials\" _
& "Build Plan DTW Reports\DataWHSreports\" & curDate
& "_DWHS_PEN EU Fixed.xlsx"
Set wb = Workbooks.Open(FileName:=Fname, UpdateLinks:=False, Notify:=False)
' ~~> Other cool stuff goes here
wb.Close False ' Close the opened workbook; False indicates to not save changes