Langkah 5 - Contoh Nyata

Menghapus Semua Baris Tabel yang Berisi String Teks Tertentu di Kolom Pertama

(Oleh Word MVP Bill Coan)

Sub DeleteRows() 

Dim TargetText As String
Dim oRow As Row
If Selection.Information(wdWithInTable) = False Then Exit Sub
 
TargetText = InputBox$("Enter target text:", "Delete Rows")
 
For Each oRow In Selection.Tables(1).Rows
 
If oRow.Cells(1).Range.Text = TargetText & vbCr & Chr(7) Then oRow.Delete

Next oRow
End Sub

Menghapus Semua Baris Kosong dalam sebuah Tabel

(Oleh Word MVP Dave Rado dan Ibby)

Public Sub DeleteEmptyRows()
Dim oTable As Table, oRow As Range, oCell As Cell, Counter As Long, _
NumRows As Long, TextInRow As Boolean

' Specify which table you want to work on.
Set oTable = Selection.Tables(1)

' Set a range variable to the first row's range
Set oRow = oTable.Rows(1).Range
NumRows = oTable.Rows.Count
Application.ScreenUpdating = False

For Counter = 1 To NumRows
StatusBar = "Row " & Counter
TextInRow = False

For Each oCell In oRow.Rows(1).Cells
If Len(oCell.Range.Text) > 2 Then
'end of cell marker is actually 2 characters
TextInRow = True
Exit For
End If
Next oCell

If TextInRow Then
Set oRow = oRow.Next(wdRow)
Else
oRow.Rows(1).Delete
End If

Next Counter

Application.ScreenUpdating = True

End Sub

Menghapus Kotak Teks Kosong dalam Presentasi

Sub RemoveEmptyTextBoxes()
Dim SlideObj As Slide
Dim ShapeObj As Shape
Dim ShapeIndex As Integer
For Each SlideObj In ActivePresentation.Slides
For ShapeIndex = SlideObj.Shapes.Count To 1 Step -1
Set ShapeObj = SlideObj.Shapes(ShapeIndex)
If ShapeObj.Type = msoTextBox Then
If Trim(ShapeObj.TextFrame.TextRange.Text) = "" Then
ShapeObj.Delete
End If
End If
Next ShapeIndex
Next SlideObj
End Sub

 Langkah 1 - Mulai dengan Perekam Makro

Langkah 2 - Membaca dan memahami Kode

Langkah 3 - Mempelajari Fundamental Pemrograman

Langkah 4 - Berbagi Makro Anda dengan Orang Lain

Langkah 5 - Contoh Nyata

Kembangkan keterampilan Anda
Jelajahi pelatihan
Dapatkan fitur baru terlebih dahulu
Gabung ke Office Insiders

Apakah informasi ini bermanfaat?

Terima kasih atas umpan balik Anda!

Terima kasih atas umpan balik Anda! Sepertinya menghubungkan Anda ke salah satu agen dukungan Office kami akan sangat membantu.

×