ww.wxcc.net
当前位置:首页 >> vBA打开指定文件夹 >>

vBA打开指定文件夹

直接使用Shell函数,使用explorer.exe来打开文件夹即可。代码如下: Sub showdir() Shell "explorer.exe D:\dir", vbNormalFocusEnd Sub效果如下: Shell 函数说明运行可执行程序并在成功时返回表示程序的任务 ID 的 Variant (Double),否则返回...

sub nn() Workbooks.Open Filename:="C:\Documents and Settings\Excel\Example.xls " workbooks("Example.xls").worksheets(1) '对工作表1的引用就可以了 end sub 这些语句都不用去记,你通过录制宏就可以完全获得这种语句

注意 c:\a 目录下的文件不要太多,免得死机 Sub 打开excel表格() Dim myPath$, myFile$, AK As Workbook Application.ScreenUpdating = False '冻结屏幕,以防屏幕抖动 myPath = "c:\a\" '把文件路径定义给变量 myFile = Dir(myPath & "*.xls") '...

Sub Read_Word() Dim worDoc As object Dim wordappl As object Dim mydoc As String Dim myappl As String mydoc = thisworkbook.path & "\" & "文件名.doc" '本文档目录下的doc文件,这里可以直接改成路径+文件名的形式 Set wordappl = C...

Sub GetFolder() Dim FolderName, FileName, MyFolder, MyFile As String FolderName = "abc" FileName = "abc.xls" MyFolder = Dir("D:\" & FolderName, 16) MyFile = Dir("D:\" & FolderName & "\" & FileName, 16) If MyFolder "" Then MsgBo...

打开文件如下: Workbooks.Open ("C:\对账单\对帐单.xlsx") 这里你可以把“C:\对账单\”换成你的绝对路径, 你可以用:a = ThisWorkbook.Path a = ThisWorkbook.Path Workbooks.Open ("" & a & "&" \ "&对帐单.xlsx") 来获取你当前表的绝对路径,...

参考下面的代码: Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Application.ScreenUpdating = False If MsgBox("需要操作的数据表是:EXCEL2003 格式,请选择:是!" & Chr(13) & "" & Chr(13) & "需要操作的数据表是:EXCEL2...

使用VBA搜索文件并将文件放到指定文件夹,参考代码如下: Dim lngRow As Integer Dim lngMaxRows As Integer Dim strFileName As String Dim strSrcFilePath As String Dim strDesFilePath As String Dim strSrcPath As String: strSrcPath = "C...

如果能确保文件夹下类似2006-08-**.xls 或者2006-08-**.xlsx的文件只有一个,可用把如下代码 Sub xx()Dim yy, mm, pth, fn, iyy = [f3]pth = "D:\" & yy & "\"For i = [f4] To 12 fn = Dir(pth & yy & "-" & Format(i, "00") & "-*.*") If fn ""...

Sub getFiles() Dim MyFile As String Dim count As Integer Const filePath = "E:\test\" count = 1 MyFile = Dir(filePath & "*.txt") Debug.Print "1、" & MyFile Do While MyFile "" If InStr(MyFile, "test") > 0 Then Debug.Print MyFile ...

网站首页 | 网站地图
All rights reserved Powered by www.ww.wxcc.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com