文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 高等教育 > 理学 > 第9章 文件操作代码【超实用VBA】
侵权投诉

第9章 文件操作代码【超实用VBA】

VBA代码精华,VBA学习的捷径! excel,VBA,excelVBA,VBA代码,VBA教学

范例141 复制指定的文件 Sub CopyingFiles()

Dim SourceFile As String

Dim DestinationFile As String

SourceFile = ThisWorkbook.Path & "\123.xlsx"

DestinationFile = ThisWorkbook.Path & "\ABC\abc.xlsx"

FileCopy SourceFile, DestinationFile

End Sub

范例142 删除指定的文件

Sub DeleteFiles()

Dim myFile As String

myFile = ThisWorkbook.Path & "\123.xlsx"

If Dir(myFile) <> "" Then Kill myFile

End Sub

范例143 使用WSH处理文件

143-1 获取文件信息 Sub FileInformation()

Dim MyFile As Object

Dim Str As String

Dim StrMsg As String

Str = ThisWorkbook.Path & "\123.xlsx"

Set MyFile = CreateObject("Scripting.FileSystemObject")

With MyFile.Getfile(Str)

StrMsg = StrMsg & "文件名称:" & .Name & Chr(13) _

& "文件创建日期:" & .DateCreated & Chr(13) _

& "文件修改日期:" & .DateLastModified & Chr(13) _

& "文件访问日期:" & .DateLastAccessed & Chr(13) _

& "文件保存路径:" & .ParentFolder

End With

MsgBox StrMsg

Set MyFile = Nothing

End Sub

98

上一页第5页

你可能喜欢

  • VBA程序设计
  • Excel使用技巧大全(超
  • Excel_VBA对象
  • 文件处理
  • VBA实例
  • Excel教程

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email