word
实现功能:
遍历某个文件夹下的所有word文档,并取消每个文档的智能标记
Public Sub chao()
Dim path As String, offDocument As Document, test As String
path = "E:\chao\11111111111111\"
Dim fso As New FileSystemObject
Dim file As file
For Each file In fso.GetFolder(path).files
test = file.Name
ChangeFileOpenDirectory "E:\chao\11111111111111\\"
Documents.Open FileName:=test, ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
ActiveDocument.EmbedSmartTags = True
ActiveDocument.Save
ActiveWindow.Close
Next
End Sub
excel
实现功能:
遍历某个文件夹下的所有excel表,并取出每个文件的最后一行复制到另一个新文件中
Public Sub test()
Dim path As String, test As String
path = "E:\chao\11111111111111"
Dim fso As New FileSystemObject
Dim file As file
For Each file In fso.GetFolder(path).Files
test = file.Name
ChDir "E:\chao\11111111111111\"
Workbooks.Open Filename:=test
Dim count As Integer
With Sheets(1)
count = .UsedRange.Rows.count
Rows(count).Select
Selection.Copy
End With
Workbooks.Open Filename:="E:\chao\22222222\test.xlsx"
Dim newcount As Integer
With Sheets(1)
newcount = .UsedRange.Rows.count
Rows(newcount + 2).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWindow.Close
End With
ActiveWindow.Close
Next
End Sub