word vba删除 vba word 删除指定行
摘要:Word VBA中,如何根据内容删除一行? Sub DelBlank()Dim i as Paragraph, n as LongApplication ScreenUpdating = FalseF...
发布日期:2020-08-17Word 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
删除小图片的宏,请修改 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 If myInlineShape.Height Next "缺少FOR循环End Sub
如何用vba删除word前几个段落的段首空格(可选中的空格,不是?
示例代码如下:Sub 宏1()For i = 1 To ThisDocument.Tables.Counts = ThisDocument.Tables(i).Cell(1, 2).Range.TextIf Trim(s) = "" ThenMsgBox ("无数据" & s)ElseMsgBox ("有数据" & s)End IfNextEnd Sub
如何vba删除word前几段落段首空格?段落前的空格数是不固定的
从后面往前删除就可以保持前面的位置。
Private Function MyFunction9()Dim I As Long, J As LongFor I = 1 To Range("A65536").End(xlUp).Row "最大行数For J = Range("A65536").End(xlUp).Row To I + 1 Step -1 "这里的最大行数看似和上面一样,但是其实它是不一样的,I 的是固定的,J 的是不固定。
If Range("A" & I).Value = Range("A" & J).Value Then Rows(J).DeleteNextNextEnd Function
如何用EXCEL的vba删除WORD的分页符
应该可以实现,删除最后一页可以吧 !!!!!!!!!!!Sub 删除最后页()Dim ra As RangeDim ra_1 As RangeDim ra_2 As RangeApplication.ActiveDocument.SelectPageCount = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)Set ra = Selection.RangeSelection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=PageCountSelection.SelectSet ra_1 = Selection.RangeSelection.EndKey Unit:=wdStorySelection.SelectSet ra_2 = Selection.Rangera.Start = ra_1.Startra.End = ra_2.Endra.SelectSelection.DeleteSelection.TypeBackspaceEnd Sub
批量删除word中的某一页(求VBA代码)
Public StartPageNum As Integer, EndPageNum As Integer Sub 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 If For 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 oFile End Sub