loadhigh:
每次您的指导都能让我的问题迎刃而解,非常感谢!
但是还存在一个问题,即以Weekinput = CurDir
ld = Dir(Weekinput & "\*" & DayStr & "*.xls")
取不到想要的文件夹目录,以至不能继续下面的子程序
Option Compare Database Dim xlapp As New Excel.Application Dim xlbook As Excel.Workbook Dim xlsheet As Excel.Worksheet Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset
Public Sub 单目录采集日报() ' Dim xlapp As New Excel.Application ' Dim xlbook As Excel.Workbook ' Dim cnn As New ADODB.Connection ' Dim rst As New ADODB.Recordset Dim Dayi As Integer Dateinput = CDate(InputBox("请输入日报日期", 系统提示, Date - 1)) Dayi = Day(Dateinput) Monthi = Month(Dateinput) DayStr = Monthi & "月" & Dayi & "日" If xlapp.GetOpenFilename = False Then Resume Weekinput = CurDir ld = Dir(Weekinput & "\*" & DayStr & "*.xls") Do While ld <> "" ' 开始循环。 ' 跳过当前的目录及上层目录。 'If ld <> "." And ld <> ".." Then ' 使用位比较来确定 MyName 代表一目录。 Set xlbook = xlapp.Workbooks.Open(ld) xlbook.Worksheets(Format(Dayi)).Activate Set xlsheet = xlbook.Worksheets(Format(Dayi)) 日报采集 xlbook.Close SaveChanges:=False ' xlbook.Close xlapp.Quit rst.Close Set xlbook = Nothing Set xlapp = Nothing Set rst = Nothing ' End If ld = Dir ' 查找下一个目录。 Loop End Sub
[此贴子已经被作者于2004-2-20 13:01:38编辑过] |