返回当前默认文件路径:
Application.DefaultFilePath
返回应用程序完整路径
Application.Path
返回当前工作薄的路径
ThisWorkbook.Path
Application.ActiveWorkbook.Path 只返回路径
Application.ActiveWorkbook.FullName 返回路径及工作簿文件名
Application.ActiveWorkbook.Name 返回工作簿文件名
将当前路径设置为选择文件对话框的默认路径:
Set target = Worksheets(SHEET_CONFIG).Range(RNG_CFG_TEMPLATE)
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "。。。"
.InitialFileName = Application.ActiveWorkbook.Path //将当前路径设置为默认路径
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "文件模板", "*.xls"
If .Show = True Then
target.Value = .SelectedItems(1)
End If
End With
sum函数的使用--
With outBook.Worksheets(SHEET_DATA_TRHKSK)
.Cells(6, 8).Value = WorksheetFunction.Sum(.Range(.Cells(3, 8), .Cells(5, 8)))
End With
行的copy,paste
With outBook.Worksheets(SHEET_DATA_TRHKSK)
.Rows(1).Copy
.Rows(2).PasteSpecial Paste:=xlAll
End With