VBA 删除当前文件目录下的文件
Sub DelBlank()Dim i as Paragraph, n as LongApplication.ScreenUpdating = FalseFor Each i In ActiveDocument.ParagraphsIf Len(i.Range) = 1 Theni.Range.Deleten = n + 1End IfNextMsgBox "共删除空白段落" & n &; "个。
"Application.ScreenUpdating = TrueEnd Sub摘自 EXCELHOME
vba如何实现:(word)清除格式?
'你想删除的文件的名称例如文件名是中国什么省汇总.xlsFN = "中国什么省汇总.xls"Dim FileName As String FileName = Dir("D:\报表\*.xls") Do While FileName "" If FileName = FN Then Kill "D:\报表\" & FileName End If FileName = Dir Loop...
VBA修改word文档
开启模糊查询即可,再判断一下查找的长度Sub 分章()Set myrange = ActiveDocument.ContentFor n = 1 To 8myrange.Find.Execute findtext:="第*章", Forward:=True, MatchWildcards:=TrueIf myrange.End - myrange.Start < 20 Thenmyrange.Style = ActiveDocument.Styles("标题 2")End IfNextEnd Sub测试运行了下,效果有点不好,修改一下Sub 分章()Set myrange = ActiveDocument.ContentFor n = 1 To 8myrange.Find.Execute findtext:="第*章", Forward:=True, MatchWildcards:=TrueIf myrange.End - myrange.Start < 20 Thenmyrange.Style = ActiveDocument.Styles("标题 2")Elsemyrange.Start = myrange.Start + 1End IfNextEnd Sub
删除小图片的宏,请修改 word vba
Sub a_dele_little_picture()On Error Resume NextSelection.HomeKey wdStory '光标移到最前面。
Dim iShape1 As Shape '图片全部修改为嵌入式For Each iShape1 In ActiveDocument.ShapesiShape1.ConvertToInlineShapeNextDim myInlineShape As InlineShapeFor Each myInlineShape In ActiveDocument.InlineShapes '缺少FOR循环If myInlineShape.Width < CentimetersToPoints(0.43) Then myInlineShape.Delete '删除极小图If myInlineShape.Height < CentimetersToPoints(0.43) Then myInlineShape.Delete '删除极小图Next '缺少FOR循环End Sub
怎样使用VBA批量删除word中空行
Sub DelBlank()Dim i As Paragraph, n As IntegerApplication.ScreenUpdating = FalseFor Each i In ActiveDocument.ParagraphsIf Len(i.Range) = 1 Theni.Range.Deleten = n + 1End IfNextMsgBox "共删除空白段落" & n & "个"Application.ScreenUpdating = TrueEnd Sub试试上面的代码...
您好,想请问如何用VBA批量删除word中文本框(保留文字)呢?可以...
好办打开word文件,点击“文件”->;“另存为网页”->“(*.htm;*.html)”打开保存过的网页文件(用IE打开)文件->;另存为->;文本文件文本文件就是你要的 VBA:Sub deltextbox()Selection.EndKey Unit:=wdStoryDim s As ShapeFor Each s In ThisDocument.ShapesSelection.TypeText text:=s.TextFrame.TextRange.texts.DeleteNextEnd Sub
批量删除word中的某一页(求VBA代码)
Public StartPageNum As Integer, EndPageNum As IntegerSub aaa() Dim myDialog As FileDialog, oFile As Variant, oDoc As Document On Error Resume Next Set myDialog = Application.FileDialog(msoFileDialogFilePicker) myDialog.Filters.Clear '清除所有文件筛选器中的项目 myDialog.Filters.Add "所有 WORD 文件", "*.doc", 1 '增加筛选器的项目为所有WORD文件 myDialog.AllowMultiSelect = True '允许多项选择 If myDialog.Show -1 Then Exit Sub Dim SelectRange As Range DlgDelePage.Show vbModal If StartPageNum = 0 And EndPageNum = 0 Then Exit Sub End IfFor Each oFile In myDialog.SelectedItems '在所有选取项目中循环 Set oDoc = Documents.Open(FileName:=oFile, Visible:=True) 'False)Dim Pages As Integer, StartPage As Long, EndPage As Long Pages = Selection.Information(wdNumberOfPagesInDocument) If Not (StartPageNum > Pages) Then If EndPageNum > Pages Then EndPageNum = Pages If StartPageNum = 1 Then StartPage = Selection.Range Else StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=StartPageNum - 1).Start End If If EndPageNum = Pages Then EndPage = ActiveDocument.Content.End Else EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=IIf(EndPageNum - StartPageNum > 0, EndPageNum - StartPageNum + 1, 1)).End '.Start End If ActiveDocument.Range(StartPage, EndPage).Select Selection.Delete End If '删除第3页批注 ActiveDocument.Words(1).Select '将光标移到文档开始位置 Dim myRange As Range, oComment As Comment Set myRange = Selection.Range StartPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).Start EndPage = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext, Count:=3 - 1).End myRange = ActiveDocument.Range(StartPage, EndPage) If myRange.Comments.Count > 0 Then For Each oComment In myRange.Comments oComment.Delete Next End If oDoc.Save oDoc.Close Next oFileEnd Sub
转载请注明出处51数据库 » word vba 删除文件
中指秀出高潮