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

vBA打开指定文件夹

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

Private Sub CommandButton1_Click() Dim Obj As Object, Path1 Set Obj = CreateObject("shell.application") Set Path1 = Obj.BrowseForFolder(0, "选择要打开的文件夹:", 0) If Not Path1 Is Nothing Then Obj.Open (Path1.self.Path) End If...

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

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

sub openfile() Workbooks.Open Filename:="F:\test\EXCEL文件.xls" end sub

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...

打开文件一般是用Open语句的 Open "C:\1.txt" for input As #1 ........ Close #1

比如:Shell "WINWORD.EXE C:\12345.doc", vbNormalFocus 在excel中,横向选中两个单元格,就打开c:\下的12345.doc文件 Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Row > 2 And Target.Rows.Count = 1 And Target...

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

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

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