第1个回答 2013-03-29
你好,百度搜: EXCEL工作室或者VBA定制 可以为您订制该程序,回答:
Sub gg() '添加个模块1
Dim Paths As String
Pahts = Dir(ThisWorkbook.Path & "\")
Do While Paths <> ""
'所有表格的名字
MsgBox Paths
Paths = Dir
Loop
End Sub
第2个回答 2013-03-28
'excelPath = "C:\Documents and Settings\All Users\桌面"
excelPath = "D:\桌面\"
Set s = Application.FileSearch
s.LookIn = excelPath
s.Filename = "waybilldatalist*.xls" '
s.Execute '执行搜索
On Error Resume Next
'
For I = 1 To s.FoundFiles.Count
myName = s.FoundFiles(I)
myName = Split(myName, "\")(UBound(Split(myName, "\")))
If InStr(myName, "xls") > 0 Then
Dim tm As Integer
Dim td As Integer
tm = CInt(Left(Right(myName, 8), 2))
td = CInt(Left(Right(myName, 6), 2))
If MsgBox("是否导入" + CStr(tm) + "月" + CStr(td) + "日数据?", vbYesNo, "提示") = vbYes Then '6返回是,7返回否
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(excelPath + myName) '打开已经存在的EXCEL工件簿文件
xlApp.Visible = True '设置EXCEL对象可见(或不可见)
Set xlsheet = xlApp.Worksheets(Replace(myName, ".xls", "")) '设置活动工作表
If Sheets("运输方式").Cells(1, 5) = "" Then Sheets("运输方式").Cells(1, 5) = "1"
.........................................................................................
xlBook.Save
xlBook.Close
End If
End If
Next I
第3个回答 2013-03-29
你好,百度搜: EXCEL工作室或者VBA定制 可以为您订制该程序,回答:
Sub gg() '添加个模块1
Dim Paths As String
Pahts = Dir(ThisWorkbook.Path & "\")
Do While Paths <> ""
'所有表格的名字
MsgBox Paths
Paths = Dir
Loop
End Sub
第4个回答 2013-03-28
'excelPath = "C:\Documents and Settings\All Users\桌面"
excelPath = "D:\桌面\"
Set s = Application.FileSearch
s.LookIn = excelPath
s.Filename = "waybilldatalist*.xls" '
s.Execute '执行搜索
On Error Resume Next
'
For I = 1 To s.FoundFiles.Count
myName = s.FoundFiles(I)
myName = Split(myName, "\")(UBound(Split(myName, "\")))
If InStr(myName, "xls") > 0 Then
Dim tm As Integer
Dim td As Integer
tm = CInt(Left(Right(myName, 8), 2))
td = CInt(Left(Right(myName, 6), 2))
If MsgBox("是否导入" + CStr(tm) + "月" + CStr(td) + "日数据?", vbYesNo, "提示") = vbYes Then '6返回是,7返回否
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(excelPath + myName) '打开已经存在的EXCEL工件簿文件
xlApp.Visible = True '设置EXCEL对象可见(或不可见)
Set xlsheet = xlApp.Worksheets(Replace(myName, ".xls", "")) '设置活动工作表
If Sheets("运输方式").Cells(1, 5) = "" Then Sheets("运输方式").Cells(1, 5) = "1"
.........................................................................................
xlBook.Save
xlBook.Close
End If
End If
Next I