今天把公司的电脑升级成office2010 发现原本的宏不能使用 侦错发现是Application.FileSearch在2007以后的版本就不能使用了 原程式码如下: Sub AutoCopyTableTofile() defaultfile = Application.ActiveDocument.Name With Application.FileSearch .FileName = "奖惩统计表.doc" .LookIn = "c:\奖惩月报" .Execute If .FoundFiles.Count > 0 Then Documents.Open FileName:="c:\奖惩月报\奖惩统计表.doc" Documents(defaultfile).Activate Selection.Tables(1).Range.Copy Documents("奖惩统计表.doc").Activate Selection.Paste Documents(defaultfile).Close Else MsgBox ("未找到===>奖惩统计表.doc<==档案") Exit Sub End If End With End Sub
Sub 文件()Set file = CreateObject("scripting.filesystemobject")For Each fils In file.getfolder("c:\").FilesFilename = Filename & fils.Name & Chr(13)NextMsgBox FilenameEnd Sub