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

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

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

143-2 取得文件基本名 Sub FileBaseName()

Dim MyFile As Object

Dim FileName As Variant

Set MyFile = CreateObject("Scripting.FileSystemObject")

FileName = Application.GetOpenFilename

If FileName <> "False" Then

MsgBox MyFile.GetBaseName(FileName)

End If

Set MyFile = Nothing

End Sub

143-3 查找文件 Sub FindFiles()

Dim MyFile As Object

Dim Str As String

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

Set MyFile = CreateObject("Scripting.FileSystemObject")

If Not MyFile.FileExists(Str) Then

MsgBox "文件不存在!"

Else

MsgBox "文件已找到!"

End If

Set MyFile = Nothing

End Sub

143-4 搜索文件 Sub SearchFiles()

Dim MyFile As Object

Dim MyFiles As Object

Dim MyStr As String

Set MyFile = CreateObject("Scripting.FileSystemObject") _

.Getfolder(ThisWorkbook.Path)

For Each MyFiles In MyFile.Files

If InStr(MyFiles.Name, ".xlsx") <> 0 Then

MyStr = MyStr & MyFiles.Name & Chr(13)

End If

Next

MsgBox MyStr

Set MyFile = Nothing

Set MyFiles = Nothing

99

上一页第6页

你可能喜欢

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

热门文档

相关文档

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