Spaces:
No application file
No application file
Update Banner/Hitung_banner_yang_dicetak.txt
Browse files- Banner/Hitung_banner_yang_dicetak.txt +233 -132
Banner/Hitung_banner_yang_dicetak.txt
CHANGED
|
@@ -2,218 +2,325 @@ Option Explicit
|
|
| 2 |
|
| 3 |
Public Sub AmbilMultiTeksSpesifik()
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
Dim doc As Document
|
| 8 |
Dim shp As Shape
|
| 9 |
-
Dim
|
| 10 |
-
Dim
|
| 11 |
-
Dim bestRect As Shape
|
| 12 |
|
| 13 |
-
Dim
|
| 14 |
-
Dim
|
|
|
|
| 15 |
|
| 16 |
-
Dim
|
|
|
|
| 17 |
Dim laporan As String
|
| 18 |
-
Dim
|
| 19 |
-
Dim i As Long
|
| 20 |
-
|
| 21 |
-
Dim bestArea As Double
|
| 22 |
-
Dim area As Double
|
| 23 |
-
Dim w As Double
|
| 24 |
-
Dim h As Double
|
| 25 |
-
|
| 26 |
-
If ActiveDocument Is Nothing Then
|
| 27 |
-
MsgBox "Tidak ada dokumen aktif.", vbExclamation
|
| 28 |
-
Exit Sub
|
| 29 |
-
End If
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
If ActiveSelection.Shapes.Count = 0 Then
|
| 34 |
-
MsgBox "Pilih objek
|
| 35 |
-
vbExclamation, "Tidak Ada Seleksi"
|
| 36 |
Exit Sub
|
| 37 |
End If
|
| 38 |
|
| 39 |
-
Set
|
| 40 |
-
Set
|
|
|
|
| 41 |
|
| 42 |
-
'
|
| 43 |
-
' termasuk teks di dalam grup bertingkat.
|
| 44 |
For Each shp In ActiveSelection.Shapes
|
| 45 |
-
|
| 46 |
Next shp
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
Exit Sub
|
| 53 |
End If
|
| 54 |
|
| 55 |
-
'
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
KumpulkanRectangle shp, daftarRect
|
| 59 |
-
Next shp
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
|
| 71 |
-
|
| 72 |
-
bestArea = 1E+100
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
If area < bestArea Then
|
| 82 |
-
bestArea = area
|
| 83 |
-
Set bestRect = rectShape
|
| 84 |
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
End If
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
| 98 |
-
h = bestRect.SizeHeight
|
| 99 |
|
| 100 |
-
|
| 101 |
-
" Ukuran Rectangle: " & _
|
| 102 |
-
Format$(w, "0.00") & " x " & _
|
| 103 |
-
Format$(h, "0.00") & " " & _
|
| 104 |
-
DapatkanSatuanString(doc.Unit) & vbCrLf
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
" Rectangle pembungkus: TIDAK DITEMUKAN" & _
|
| 110 |
-
vbCrLf
|
| 111 |
|
| 112 |
End If
|
| 113 |
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
-
laporan =
|
| 119 |
-
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
|
|
|
| 125 |
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
End Sub
|
| 133 |
|
| 134 |
|
| 135 |
-
Private Sub
|
| 136 |
-
ByVal shp As Shape,
|
| 137 |
-
ByRef hasil As Collection)
|
| 138 |
|
| 139 |
Dim child As Shape
|
| 140 |
-
Dim txt As String
|
| 141 |
|
| 142 |
If shp.Type = cdrGroupShape Then
|
| 143 |
-
|
| 144 |
For Each child In shp.Shapes
|
| 145 |
-
|
| 146 |
Next child
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
|
| 149 |
|
| 150 |
-
End If
|
| 151 |
|
| 152 |
-
|
|
|
|
| 153 |
|
| 154 |
-
|
|
|
|
| 155 |
|
| 156 |
-
|
|
|
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
Selesai:
|
| 166 |
|
| 167 |
-
|
|
|
|
| 168 |
|
|
|
|
|
|
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
| 173 |
|
| 174 |
-
|
| 175 |
|
| 176 |
-
If shp.Type = cdrGroupShape Then
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
| 181 |
|
| 182 |
-
|
|
|
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
-
If shp.Type = cdrRectangleShape Then
|
| 187 |
-
hasil.Add shp
|
| 188 |
-
End If
|
| 189 |
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
|
|
|
|
|
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
| 196 |
|
| 197 |
-
|
|
|
|
|
|
|
| 198 |
|
| 199 |
-
|
| 200 |
-
(rect.LeftX <= txt.LeftX + TOLERANSI) And _
|
| 201 |
-
(rect.RightX >= txt.RightX - TOLERANSI) And _
|
| 202 |
-
(rect.BottomY <= txt.BottomY + TOLERANSI) And _
|
| 203 |
-
(rect.TopY >= txt.TopY - TOLERANSI)
|
| 204 |
|
| 205 |
End Function
|
| 206 |
|
| 207 |
|
| 208 |
-
Private Function
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
|
| 216 |
-
|
| 217 |
|
| 218 |
End Function
|
| 219 |
|
|
@@ -222,22 +329,16 @@ Private Function DapatkanSatuanString( _
|
|
| 222 |
ByVal satuan As cdrUnit) As String
|
| 223 |
|
| 224 |
Select Case satuan
|
| 225 |
-
|
| 226 |
Case cdrMillimeter
|
| 227 |
DapatkanSatuanString = "mm"
|
| 228 |
-
|
| 229 |
Case cdrCentimeter
|
| 230 |
DapatkanSatuanString = "cm"
|
| 231 |
-
|
| 232 |
Case cdrInch
|
| 233 |
DapatkanSatuanString = "inch"
|
| 234 |
-
|
| 235 |
Case cdrPixel
|
| 236 |
DapatkanSatuanString = "px"
|
| 237 |
-
|
| 238 |
Case Else
|
| 239 |
DapatkanSatuanString = "unit"
|
| 240 |
-
|
| 241 |
End Select
|
| 242 |
|
| 243 |
End Function
|
|
|
|
| 2 |
|
| 3 |
Public Sub AmbilMultiTeksSpesifik()
|
| 4 |
|
| 5 |
+
Dim semuaShape As Collection
|
| 6 |
+
Dim semuaRect As Collection
|
| 7 |
+
Dim rectValid As Collection
|
| 8 |
|
|
|
|
| 9 |
Dim shp As Shape
|
| 10 |
+
Dim rect As Shape
|
| 11 |
+
Dim kandidat As Shape
|
|
|
|
| 12 |
|
| 13 |
+
Dim i As Long, j As Long
|
| 14 |
+
Dim pemilik As Long
|
| 15 |
+
Dim jumlahBanner As Long
|
| 16 |
|
| 17 |
+
Dim teks As String
|
| 18 |
+
Dim teksBanner() As String
|
| 19 |
Dim laporan As String
|
| 20 |
+
Dim satuan As String
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
Dim minMargin As Double
|
| 23 |
+
Dim maxMargin As Double
|
| 24 |
+
Dim minX As Double, maxX As Double
|
| 25 |
+
Dim minY As Double, maxY As Double
|
| 26 |
+
Dim marginKiri As Double, marginKanan As Double
|
| 27 |
+
Dim marginAtas As Double, marginBawah As Double
|
| 28 |
+
Dim luas As Double, luasTerbaik As Double
|
| 29 |
+
Dim adaObjek As Boolean
|
| 30 |
|
| 31 |
If ActiveSelection.Shapes.Count = 0 Then
|
| 32 |
+
MsgBox "Pilih semua objek banner terlebih dahulu.", vbExclamation
|
|
|
|
| 33 |
Exit Sub
|
| 34 |
End If
|
| 35 |
|
| 36 |
+
Set semuaShape = New Collection
|
| 37 |
+
Set semuaRect = New Collection
|
| 38 |
+
Set rectValid = New Collection
|
| 39 |
|
| 40 |
+
' Kumpulkan objek daun; grup ditelusuri hingga isinya.
|
|
|
|
| 41 |
For Each shp In ActiveSelection.Shapes
|
| 42 |
+
KumpulkanShapeRekursif shp, semuaShape
|
| 43 |
Next shp
|
| 44 |
|
| 45 |
+
' Kumpulkan Rectangle yang unik.
|
| 46 |
+
For i = 1 To semuaShape.Count
|
| 47 |
+
Set shp = semuaShape(i)
|
| 48 |
+
|
| 49 |
+
If shp.Type = cdrRectangleShape Then
|
| 50 |
+
If Not KoleksiBerisiShape(semuaRect, shp) Then
|
| 51 |
+
semuaRect.Add shp
|
| 52 |
+
End If
|
| 53 |
+
End If
|
| 54 |
+
Next i
|
| 55 |
+
|
| 56 |
+
If semuaRect.Count = 0 Then
|
| 57 |
+
MsgBox "Tidak ditemukan Rectangle dalam seleksi.", vbExclamation
|
| 58 |
Exit Sub
|
| 59 |
End If
|
| 60 |
|
| 61 |
+
' Konversi jarak dari cm ke satuan dokumen.
|
| 62 |
+
minMargin = CmKeSatuanDokumen(2.5)
|
| 63 |
+
maxMargin = CmKeSatuanDokumen(10)
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
' Validasi setiap Rectangle berdasarkan jarak ke desain.
|
| 66 |
+
For i = 1 To semuaRect.Count
|
| 67 |
|
| 68 |
+
Set rect = semuaRect(i)
|
| 69 |
+
adaObjek = False
|
| 70 |
|
| 71 |
+
minX = 0: maxX = 0
|
| 72 |
+
minY = 0: maxY = 0
|
| 73 |
|
| 74 |
+
For j = 1 To semuaShape.Count
|
| 75 |
|
| 76 |
+
Set shp = semuaShape(j)
|
|
|
|
| 77 |
|
| 78 |
+
' Gunakan objek desain, bukan Rectangle atau grup.
|
| 79 |
+
If shp.Type <> cdrRectangleShape _
|
| 80 |
+
And shp.Type <> cdrGroupShape Then
|
| 81 |
|
| 82 |
+
If RectangleMencakupShape(rect, shp) Then
|
| 83 |
|
| 84 |
+
If Not adaObjek Then
|
| 85 |
+
minX = shp.LeftX
|
| 86 |
+
maxX = shp.RightX
|
| 87 |
+
minY = shp.BottomY
|
| 88 |
+
maxY = shp.TopY
|
| 89 |
+
adaObjek = True
|
| 90 |
+
Else
|
| 91 |
+
If shp.LeftX < minX Then minX = shp.LeftX
|
| 92 |
+
If shp.RightX > maxX Then maxX = shp.RightX
|
| 93 |
+
If shp.BottomY < minY Then minY = shp.BottomY
|
| 94 |
+
If shp.TopY > maxY Then maxY = shp.TopY
|
| 95 |
+
End If
|
| 96 |
|
|
|
|
|
|
|
|
|
|
| 97 |
End If
|
| 98 |
+
End If
|
| 99 |
+
|
| 100 |
+
Next j
|
| 101 |
+
|
| 102 |
+
If adaObjek Then
|
| 103 |
+
|
| 104 |
+
marginKiri = minX - rect.LeftX
|
| 105 |
+
marginKanan = rect.RightX - maxX
|
| 106 |
+
marginAtas = rect.TopY - maxY
|
| 107 |
+
marginBawah = minY - rect.BottomY
|
| 108 |
+
|
| 109 |
+
If MarginValid(marginKiri, minMargin, maxMargin) _
|
| 110 |
+
And MarginValid(marginKanan, minMargin, maxMargin) _
|
| 111 |
+
And MarginValid(marginAtas, minMargin, maxMargin) _
|
| 112 |
+
And MarginValid(marginBawah, minMargin, maxMargin) Then
|
| 113 |
+
|
| 114 |
+
rectValid.Add rect
|
| 115 |
|
| 116 |
End If
|
| 117 |
|
| 118 |
+
End If
|
| 119 |
+
|
| 120 |
+
Next i
|
| 121 |
+
|
| 122 |
+
If rectValid.Count = 0 Then
|
| 123 |
+
MsgBox "Tidak ada Rectangle yang memenuhi jarak 2,5–10 cm." & _
|
| 124 |
+
vbCrLf & _
|
| 125 |
+
"Periksa seleksi, satuan dokumen, dan jarak pembatas.", _
|
| 126 |
+
vbExclamation, "Pembatas Tidak Ditemukan"
|
| 127 |
+
Exit Sub
|
| 128 |
+
End If
|
| 129 |
+
|
| 130 |
+
ReDim teksBanner(1 To rectValid.Count)
|
| 131 |
+
|
| 132 |
+
' Alokasikan setiap teks penanda ke satu Rectangle valid.
|
| 133 |
+
For i = 1 To semuaShape.Count
|
| 134 |
+
|
| 135 |
+
Set shp = semuaShape(i)
|
| 136 |
+
|
| 137 |
+
If shp.Type = cdrTextShape Then
|
| 138 |
+
|
| 139 |
+
teks = NormalisasiTeks(AmbilIsiTeks(shp))
|
| 140 |
+
|
| 141 |
+
If InStr(1, teks, "x", vbTextCompare) > 0 _
|
| 142 |
+
And InStr(1, teks, "//", vbBinaryCompare) > 0 Then
|
| 143 |
+
|
| 144 |
+
pemilik = 0
|
| 145 |
+
luasTerbaik = 0
|
| 146 |
+
|
| 147 |
+
For j = 1 To rectValid.Count
|
| 148 |
+
|
| 149 |
+
Set kandidat = rectValid(j)
|
| 150 |
|
| 151 |
+
If RectangleMencakupShape(kandidat, shp) Then
|
| 152 |
|
| 153 |
+
luas = Abs(kandidat.SizeWidth * _
|
| 154 |
+
kandidat.SizeHeight)
|
| 155 |
|
| 156 |
+
If pemilik = 0 Or luas < luasTerbaik Then
|
| 157 |
+
pemilik = j
|
| 158 |
+
luasTerbaik = luas
|
| 159 |
+
End If
|
| 160 |
|
| 161 |
+
End If
|
|
|
|
| 162 |
|
| 163 |
+
Next j
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
+
If pemilik > 0 Then
|
| 166 |
+
If Len(teksBanner(pemilik)) = 0 Then
|
| 167 |
+
teksBanner(pemilik) = teks
|
| 168 |
+
Else
|
| 169 |
+
teksBanner(pemilik) = teksBanner(pemilik) & _
|
| 170 |
+
" | " & teks
|
| 171 |
+
End If
|
| 172 |
+
End If
|
| 173 |
|
| 174 |
+
End If
|
|
|
|
|
|
|
| 175 |
|
| 176 |
End If
|
| 177 |
|
| 178 |
+
Next i
|
| 179 |
|
| 180 |
+
' Laporan.
|
| 181 |
+
satuan = DapatkanSatuanString(ActiveDocument.Unit)
|
| 182 |
|
| 183 |
+
laporan = "LAPORAN UKURAN BANNER" & vbCrLf & _
|
| 184 |
+
String(40, "-") & vbCrLf
|
| 185 |
|
| 186 |
+
jumlahBanner = rectValid.Count
|
| 187 |
+
|
| 188 |
+
For i = 1 To rectValid.Count
|
| 189 |
+
|
| 190 |
+
Set rect = rectValid(i)
|
| 191 |
|
| 192 |
+
teks = Trim$(teksBanner(i))
|
| 193 |
+
If Len(teks) = 0 Then teks = "unknown"
|
| 194 |
|
| 195 |
+
laporan = laporan & _
|
| 196 |
+
i & ". Banner: " & teks & vbCrLf & _
|
| 197 |
+
" Lebar : " & Format$(rect.SizeWidth, "0.00") & _
|
| 198 |
+
" " & satuan & vbCrLf & _
|
| 199 |
+
" Tinggi : " & Format$(rect.SizeHeight, "0.00") & _
|
| 200 |
+
" " & satuan & vbCrLf & vbCrLf
|
| 201 |
|
| 202 |
+
Next i
|
| 203 |
+
|
| 204 |
+
laporan = laporan & String(40, "-") & vbCrLf & _
|
| 205 |
+
"TOTAL BANNER: " & jumlahBanner
|
| 206 |
+
|
| 207 |
+
MsgBox laporan, vbInformation, _
|
| 208 |
+
"Selesai - " & jumlahBanner & " Banner"
|
| 209 |
|
| 210 |
End Sub
|
| 211 |
|
| 212 |
|
| 213 |
+
Private Sub KumpulkanShapeRekursif( _
|
| 214 |
+
ByVal shp As Shape, ByRef daftar As Collection)
|
|
|
|
| 215 |
|
| 216 |
Dim child As Shape
|
|
|
|
| 217 |
|
| 218 |
If shp.Type = cdrGroupShape Then
|
|
|
|
| 219 |
For Each child In shp.Shapes
|
| 220 |
+
KumpulkanShapeRekursif child, daftar
|
| 221 |
Next child
|
| 222 |
+
Else
|
| 223 |
+
If Not KoleksiBerisiShape(daftar, shp) Then
|
| 224 |
+
daftar.Add shp
|
| 225 |
+
End If
|
| 226 |
+
End If
|
| 227 |
|
| 228 |
+
End Sub
|
| 229 |
|
|
|
|
| 230 |
|
| 231 |
+
Private Function KoleksiBerisiShape( _
|
| 232 |
+
ByVal daftar As Collection, ByVal cari As Shape) As Boolean
|
| 233 |
|
| 234 |
+
Dim i As Long
|
| 235 |
+
Dim item As Shape
|
| 236 |
|
| 237 |
+
For i = 1 To daftar.Count
|
| 238 |
+
Set item = daftar(i)
|
| 239 |
|
| 240 |
+
If item Is cari Then
|
| 241 |
+
KoleksiBerisiShape = True
|
| 242 |
+
Exit Function
|
| 243 |
+
End If
|
| 244 |
+
Next i
|
| 245 |
|
| 246 |
+
KoleksiBerisiShape = False
|
| 247 |
|
| 248 |
+
End Function
|
| 249 |
|
|
|
|
| 250 |
|
| 251 |
+
Private Function RectangleMencakupShape( _
|
| 252 |
+
ByVal rect As Shape, ByVal shp As Shape) As Boolean
|
| 253 |
|
| 254 |
+
Dim tol As Double
|
| 255 |
+
tol = 0.001
|
| 256 |
|
| 257 |
+
RectangleMencakupShape = _
|
| 258 |
+
(rect.LeftX <= shp.LeftX + tol) And _
|
| 259 |
+
(rect.RightX >= shp.RightX - tol) And _
|
| 260 |
+
(rect.TopY >= shp.TopY - tol) And _
|
| 261 |
+
(rect.BottomY <= shp.BottomY + tol)
|
| 262 |
|
| 263 |
+
End Function
|
| 264 |
|
|
|
|
| 265 |
|
| 266 |
+
Private Function MarginValid( _
|
| 267 |
+
ByVal margin As Double, _
|
| 268 |
+
ByVal minimum As Double, _
|
| 269 |
+
ByVal maksimum As Double) As Boolean
|
| 270 |
|
| 271 |
+
MarginValid = (margin >= minimum - 0.001) _
|
| 272 |
+
And (margin <= maksimum + 0.001)
|
| 273 |
|
| 274 |
+
End Function
|
| 275 |
|
|
|
|
|
|
|
|
|
|
| 276 |
|
| 277 |
+
Private Function AmbilIsiTeks(ByVal shp As Shape) As String
|
| 278 |
+
|
| 279 |
+
On Error GoTo Gagal
|
| 280 |
+
AmbilIsiTeks = shp.Text.Story.Text
|
| 281 |
+
Exit Function
|
| 282 |
|
| 283 |
+
Gagal:
|
| 284 |
+
AmbilIsiTeks = ""
|
| 285 |
|
| 286 |
+
End Function
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
Private Function NormalisasiTeks(ByVal teks As String) As String
|
| 290 |
|
| 291 |
+
teks = Replace(teks, vbCr, " ")
|
| 292 |
+
teks = Replace(teks, vbLf, " ")
|
| 293 |
+
teks = Replace(teks, vbTab, " ")
|
| 294 |
|
| 295 |
+
NormalisasiTeks = Trim$(teks)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
End Function
|
| 298 |
|
| 299 |
|
| 300 |
+
Private Function CmKeSatuanDokumen(ByVal cm As Double) As Double
|
| 301 |
+
|
| 302 |
+
Select Case ActiveDocument.Unit
|
| 303 |
+
|
| 304 |
+
Case cdrMillimeter
|
| 305 |
+
CmKeSatuanDokumen = cm * 10#
|
| 306 |
+
|
| 307 |
+
Case cdrCentimeter
|
| 308 |
+
CmKeSatuanDokumen = cm
|
| 309 |
+
|
| 310 |
+
Case cdrInch
|
| 311 |
+
CmKeSatuanDokumen = cm / 2.54
|
| 312 |
+
|
| 313 |
+
Case cdrPixel
|
| 314 |
+
Err.Raise vbObjectError + 1001, _
|
| 315 |
+
"CmKeSatuanDokumen", _
|
| 316 |
+
"Satuan pixel belum didukung untuk jarak fisik cm."
|
| 317 |
|
| 318 |
+
Case Else
|
| 319 |
+
Err.Raise vbObjectError + 1002, _
|
| 320 |
+
"CmKeSatuanDokumen", _
|
| 321 |
+
"Satuan dokumen belum didukung. Gunakan mm, cm, atau inch."
|
| 322 |
|
| 323 |
+
End Select
|
| 324 |
|
| 325 |
End Function
|
| 326 |
|
|
|
|
| 329 |
ByVal satuan As cdrUnit) As String
|
| 330 |
|
| 331 |
Select Case satuan
|
|
|
|
| 332 |
Case cdrMillimeter
|
| 333 |
DapatkanSatuanString = "mm"
|
|
|
|
| 334 |
Case cdrCentimeter
|
| 335 |
DapatkanSatuanString = "cm"
|
|
|
|
| 336 |
Case cdrInch
|
| 337 |
DapatkanSatuanString = "inch"
|
|
|
|
| 338 |
Case cdrPixel
|
| 339 |
DapatkanSatuanString = "px"
|
|
|
|
| 340 |
Case Else
|
| 341 |
DapatkanSatuanString = "unit"
|
|
|
|
| 342 |
End Select
|
| 343 |
|
| 344 |
End Function
|