-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorelDrawRecorder.bas
1870 lines (1799 loc) · 67.1 KB
/
corelDrawRecorder.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Attribute VB_Name = "RecordedMacros"
Option Explicit
Private Const ssAppName As String = "Myprint"
Private Const ssSection As String = "X7_cr"
Sub OutLineC()
' Recorded 4/19/2015
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection.SetOutlineProperties BehindFill:=cdrTrue, LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
End Sub
Sub Macro1()
'MsgBox Application.FrameWork.MainMenu.Controls(12).DescriptionText
MsgBox Application.FrameWork.FrameWindows.First.Caption
End Sub
Sub BehindFill()
' Recorded 7/19/2015
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
'OrigSelection.SetOutlineProperties BehindFill:=cdrTrue, LineJoin:=cdrOutlineRoundLineJoin
OrigSelection.SetOutlineProperties LineJoin:=cdrOutlineRoundLineJoin
End Sub
Sub sizeSS()
' Recorded 7/4/2015
ActiveDocument.BeginCommandGroup "SizeSS"
ActiveDocument.Unit = cdrMillimeter
'ActiveDocument.ReferencePoint = cdrMiddleLeft
ActiveDocument.ReferencePoint = cdrCenter
Dim sz, sz_2 As Double
Dim indexS, index2 As Integer
indexS = 1
sz = 200
index2 = 2
sz_2 = 100
Dim cC As Page
For Each cC In ActiveDocument.Pages
If cC.Shapes(indexS).SizeWidth > sz Then cC.Shapes(indexS).SizeWidth = sz
'If cc.Shapes(index2).SizeWidth > sz_2 Then cc.Shapes(index2).SizeWidth = sz_2
'cc.Shapes(indexS).Move -1.25, 0
Next cC
ActiveDocument.EndCommandGroup
End Sub
Sub sizeSS_Selected()
' Fix Shape size selected
ActiveDocument.BeginCommandGroup "SizeInSelect"
ActiveDocument.Unit = cdrMillimeter
'ActiveDocument.ReferencePoint = cdrMiddleLeft
ActiveDocument.ReferencePoint = cdrCenter
Dim s As Shape
Dim sz, sz_2 As Double
Dim indexS, index2 As Integer
sz = 38
For Each s In ActiveSelection.Shapes
If s.SizeWidth > sz Then s.SizeWidth = sz
Next
ActiveDocument.EndCommandGroup
End Sub
Sub sizeFix(ShapeIndex, ShapeSize, Condition, Direction, newSize)
' Thu tu - Kich thuoc - Dieu kien - huong - KT moi
ActiveDocument.Unit = cdrMillimeter
'ActiveDocument.ReferencePoint = cdrCenter
ActiveDocument.ReferencePoint = Direction
Dim cC As Page
For Each cC In ActiveDocument.Pages
tmp = cC.Shapes(ShapeIndex).SizeWidth
If Evaluate(tmp & Condition & ShapeSize) Then cC.Shapes(ShapeIndex).SizeWidth = newSize
Next cC
End Sub
Sub groupLikeMe()
ActiveDocument.BeginCommandGroup "Group Like Me"
Optimization = True
Dim x As Double, y As Double, w As Double, h As Double
ActiveDocument.Unit = cdrMillimeter
ActiveSelection.GetBoundingBox x, y, w, h
Dim sr As Shape
For Each sr In ActivePage.Shapes.FindShapes(Query:="@width = {" & w & " mm} & @height = {" & h & " mm}").Shapes
sr.GetBoundingBox x, y, w, h
ActivePage.SelectShapesFromRectangle(x, y, x + w, y + h, False).Group
'sr.SizeWidth = 20
'sr.SizeHeight = 60
Next
Optimization = False
ActiveDocument.EndCommandGroup
Refresh
MsgBox "Group Finish"
End Sub
Sub ExportLikeMe()
ActiveDocument.BeginCommandGroup "Export Like Me"
Optimization = True
Dim x As Double, y As Double, w As Double, h As Double
Dim i As Integer
i = 1
ActiveDocument.Unit = cdrMillimeter
ActiveSelection.GetBoundingBox x, y, w, h
Dim OrigSelection As ExportFilter
Dim fName As String
Dim wT As Long
Dim hT As Long
Dim res As Long
Dim Resolution As Long
res = 1600 'Max Size (pixels)
Resolution = 600
If ActiveSelection.Shapes.count < 1 Then
MsgBox "Vui long chon doi tuong de Export", vbCritical, "Alert!"
Exit Sub
End If
If ActiveSelection.SizeWidth < ActiveSelection.SizeHeight Then
wT = res
hT = res * ActiveSelection.SizeHeight / ActiveSelection.SizeWidth
Else
hT = res
wT = res * ActiveSelection.SizeWidth / ActiveSelection.SizeHeight
End If
fName = InputBox("nhap ten file", "File name to export", Replace(ActiveDocument.FileName, ".cdr", ""))
If fName = "" Then Exit Sub
Dim sr As Shape
For Each sr In ActivePage.Shapes.FindShapes(Query:="@width = {" & w & " mm} & @height = {" & h & " mm}").Shapes
sr.GetBoundingBox x, y, w, h
ActivePage.SelectShapesFromRectangle x, y, x + w, y + h, False
Set OrigSelection = ActiveDocument.ExportBitmap("E:\User\desktop\File maket\" & fName & "_" & i & ".jpg", cdrJPEG, cdrSelection, cdrRGBColorImage, wT, hT, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
OrigSelection.Finish
i = i + 1
Next
Optimization = False
ActiveDocument.EndCommandGroup
Refresh
MsgBox "Export Finish"
End Sub
Sub SelectLikeMe()
Dim x As Double, y As Double, w As Double, h As Double
ActiveDocument.Unit = cdrMillimeter
ActiveSelection.GetBoundingBox x, y, w, h
ActivePage.Shapes.FindShapes(Query:="@width = {" & w & " mm} & @height = {" & h & " mm}").CreateSelection
End Sub
Sub SelectLikeMe_ss()
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
For Each cC In ActiveDocument.Pages
cC.Activate
ActivePage.Shapes.FindShapes(Query:="@width < {" & 2 & " mm} & @height < {" & 2 & " mm}").Delete
Next
End Sub
Sub SelectLikeMe_small()
ActiveDocument.ReferencePoint = cdrCenter
ActiveDocument.Unit = cdrMillimeter
Dim cC As Page
'For Each cC In ActiveDocument.Pages
ActivePage.Shapes.FindShapes(Query:="@width < {1 mm} and @height < {1 mm}").Move 200, 0
'Next
End Sub
Sub SelectShapesWithRedColor()
ActivePage.Shapes.FindShapes(Query:="@colors.find('Red')").CreateSelection
End Sub
Sub selec_color_mod()
MsgBox ActiveSelection.Shapes(1).Fill.UniformColor.IsCMYK
End Sub
Sub SelectLikeMe_color()
Dim x As Double, y As Double, w As Double, h As Double
Dim RGBmode As Boolean
RGBmode = False
If ActiveSelection.Shapes(1).Fill.UniformColor.IsCMYK = False Then
Dim cR, cB, cG As Integer
cR = ActiveSelection.Shapes(1).Fill.UniformColor.RGBRed
cB = ActiveSelection.Shapes(1).Fill.UniformColor.RGBBlue
cG = ActiveSelection.Shapes(1).Fill.UniformColor.RGBGreen
ActivePage.Shapes.FindShapes(Query:="@fill.color = rgb(" & cR & ", " & cG & ", " & cB & ")").CreateSelection
Else
Dim cC, cM, cY, cK As Integer
cC = ActiveSelection.Shapes(1).Fill.UniformColor.CMYKCyan
cM = ActiveSelection.Shapes(1).Fill.UniformColor.CMYKMagenta
cY = ActiveSelection.Shapes(1).Fill.UniformColor.CMYKYellow
cK = ActiveSelection.Shapes(1).Fill.UniformColor.CMYKBlack
ActivePage.Shapes.FindShapes(Query:="@Outline.color = cmyk(" & cC & ", " & cM & ", " & cY & ", " & cK & ")").CreateSelection
End If
'ActivePage.Shapes.FindShapes(Query:="@width > {30 mm} & @height > {8 mm}").CreateSelection
End Sub
Sub BarCode2Vector()
' Recorded 12/16/2015
Dim OrigSelection As ShapeRange
Dim x, y As Double
Set OrigSelection = ActiveSelectionRange
x = ActiveSelection.PositionX
y = ActiveSelection.PositionY
OrigSelection.Cut
ActiveLayer.PasteSpecial "Metafile"
ActiveSelection.PositionX = x
ActiveSelection.PositionY = y
End Sub
Sub EditText()
Dim og As ShapeRange
Set og = ActiveSelectionRange
og.Shapes(1).Text.Story.Font = "Vni-Helve"
og.Shapes(1).Text.Story.Size = "18"
og.Shapes(1).Text.Story.Italic = False
og.Shapes(1).Text.Story.Bold = False
og.Shapes(1).Text.Story.ChangeCase cdrTextUpperCase
End Sub
Sub IMG_Export()
' Recorded 25/01/2016
Dim OrigSelection As ExportFilter
Dim fName As String
Dim w As Long
Dim h As Long
Dim res As Long
Dim Resolution As Long
res = 1200 'Max Size (pixels)
Resolution = 300
If ActiveSelection.Shapes.count < 1 Then
MsgBox "Vui long chon doi tuong de Export", vbCritical, "Alert!"
Exit Sub
End If
If ActiveSelection.SizeWidth < ActiveSelection.SizeHeight Then
w = res
h = res * ActiveSelection.SizeHeight / ActiveSelection.SizeWidth
Else
h = res
w = res * ActiveSelection.SizeWidth / ActiveSelection.SizeHeight
End If
fName = InputBox("nhap ten file", "File nameSSSS to export", Replace(ActiveDocument.FileName, ".cdr", ""))
If fName = "" Then Exit Sub
'Set OrigSelection = ActiveDocument.ExportBitmap("E:\Users\Desktop\File maket\" & fName & ".jpg", cdrJPEG, cdrSelection, cdrCMYKColorImage, w, h, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
Set OrigSelection = ActiveDocument.ExportBitmap("E:\User\desktop\File maket\" & fName & ".jpg", cdrJPEG, cdrSelection, cdrRGBColorImage, w, h, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
'Set OrigSelection = ActiveDocument.ExportBitmap("E:\User\desktop\Giao trinh phun theu tham my-My Tram\hinh new\" & fName & ".jpg", cdrJPEG, cdrSelection, cdrRGBColorImage, w, h, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
OrigSelection.Finish
End Sub
Sub IMG_multi_Export()
' Recorded 25/01/2016
Dim OrigSelection As ExportFilter
Dim fName As String
Dim w As Long
Dim h As Long
Dim res As Long
Dim Resolution As Long
Dim x As Shape
Dim Orig As ShapeRange
Dim j As Integer
j = 1
res = 1200
Resolution = 300
If ActiveSelection.Shapes.count < 1 Then
MsgBox "Vui long chon doi tuong de Export", vbCritical, "Alert!"
Exit Sub
End If
fName = InputBox("nhap ten file", "File name to export", Replace(ActiveDocument.FileName, ".cdr", ""))
If fName = "" Then Exit Sub
Set Orig = ActiveSelectionRange
For Each x In Orig
x.CreateSelection
If ActiveSelection.SizeWidth < ActiveSelection.SizeHeight Then
w = res
h = res * ActiveSelection.SizeHeight / ActiveSelection.SizeWidth
Else
h = res
w = res * ActiveSelection.SizeWidth / ActiveSelection.SizeHeight
End If
Set OrigSelection = ActiveDocument.ExportBitmap("E:\User\desktop\File maket\" & fName & j & ".jpg", cdrJPEG, cdrSelection, cdrRGBColorImage, w, h, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
OrigSelection.Finish
j = j + 1
Next
'Set OrigSelection = ActiveDocument.ExportBitmap("E:\Users\Desktop\File maket\" & fName & ".jpg", cdrJPEG, cdrSelection, cdrCMYKColorImage, w, h, 300, 300, cdrNormalAntiAliasing, True, False)
End Sub
Sub IMG_Export_page()
' Recorded 25/01/2016
Dim OrigSelection As ExportFilter
Dim pg As Page
Dim fName As String
Dim w As Long
Dim h As Long
Dim res As Long
Dim Resolution As Long
res = 1600 'Max Size (pixels)
Resolution = 600
If ActivePage.SizeWidth < ActivePage.SizeHeight Then
w = res
h = res * ActivePage.SizeHeight / ActivePage.SizeWidth
Else
h = res
w = res * ActivePage.SizeWidth / ActivePage.SizeHeight
End If
fName = InputBox("nhap ten file", "File name to export", Replace(ActiveDocument.FileName, ".cdr", ""))
If fName = "" Then Exit Sub
'Set OrigSelection = ActiveDocument.ExportBitmap("E:\Users\Desktop\File maket\" & fName & ".jpg", cdrJPEG, cdrSelection, cdrCMYKColorImage, w, h, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
For Each pg In ActiveDocument.Pages
pg.Activate
Set OrigSelection = ActiveDocument.ExportBitmap("E:\User\desktop\File maket\" & fName & "_" & pg.Name & ".jpg", cdrJPEG, cdrCurrentPage, cdrRGBColorImage, w, h, Resolution, Resolution, cdrNormalAntiAliasing, True, False)
OrigSelection.Finish
Next
End Sub
Sub My_Print()
' Print N page continous, for large page
' select print before Print
' Shortcut: Ctrl + Shift + P
Optimization = True
Dim stepPage As Integer
stepPage = 25
If stepPage = 0 Then
With ActiveDocument.PrintSettings
.PrintRange = prnCurrentPage
End With
ActiveDocument.PrintOut
Exit Sub
Else
Dim a As Integer
a = GetSetting(ssAppName, ssSection, "page", 1)
With ActiveDocument.PrintSettings
.PrintRange = prnPageRange
.PageRange = a & "-" & (a + stepPage - 1)
End With
'MsgBox a & "-" & (a + 49)
'If ActiveDocument.PrintSettings.Printer.Name <> "RICOH Aficio MP C6501" Then
' MsgBox "Ban co thuc su muon in vao may" & ActiveDocument.PrintSettings.Printer.Name, vbCritical
' Exit Sub
'End If
ActiveDocument.PrintOut
SaveSetting ssAppName, ssSection, "page", a + stepPage
ActiveDocument.Pages(a + stepPage).Activate
End If
Optimization = False
Application.Refresh
End Sub
Sub print_info()
MsgBox ActiveDocument.PrintSettings.Printer.Type
End Sub
Sub Show_current_page()
Dim a As Integer
a = GetSetting(ssAppName, ssSection, "page", 1)
MsgBox "Current page is:" & a, vbOKOnly, "My Print auto"
End Sub
Sub My_TestPrint()
' 1. Set firstpage for my_print()
' 2. Print current page
SaveSetting ssAppName, ssSection, "page", 1
Exit Sub
Dim a As Integer
With ActiveDocument.PrintSettings
.PrintRange = prnCurrentPage
End With
ActiveDocument.PrintOut
End Sub
Sub copy_shape_pos()
ActiveDocument.Unit = cdrMillimeter
ActiveSelection.Shapes(2).Stretch ActiveSelection.Shapes(2).SizeHeight / ActiveSelection.Shapes(1).SizeHeight
ActiveSelectionRange.AlignAndDistribute 3, 3, 0, 0, False, 2
ActiveSelection.Shapes(1).Move 0#, 220#
End Sub
Sub CopyText_without_format()
' Recorded 29/03/2016
' Ctrl + Numpad_9
ActiveDocument.Unit = cdrMillimeter
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
If OrigSelection.Shapes(1).Shapes.count > 1 Then
OrigSelection.Shapes(1).Shapes(1).Text.Story.Text = OrigSelection.Shapes(2).Text.Story.Text
'OrigSelection.Shapes(1).Shapes(1).Text.Story.ChangeCase cdrTextUpperCase
Else
OrigSelection.Shapes(1).Text.Story.Text = OrigSelection.Shapes(2).Text.Story.Text
'OrigSelection.Shapes(1).Fill.UniformColor.CMYKAssign 0, 100, 100, 0
'OrigSelection.Shapes(1).Text.Story.Text = Replace(OrigSelection.Shapes(2).Text.Story.Text, " ", vbCrLf)
End If
OrigSelection.Shapes(2).Selected = False
OrigSelection.Shapes(2).Delete
'If OrigSelection.Shapes(1).SizeWidth > 54 Then OrigSelection.Shapes(1).SizeWidth = 54
' Dim s1 As Shape
' Dim p As Page
' For Each p In ActiveDocument.Pages
'' p.Activate
' Set s1 = ActiveLayer.CreateRectangle(2.112248, 9.162661, 6.246106, 3.316205)
' s1.Rectangle.CornerType = cdrCornerTypeRound
' s1.Rectangle.RelativeCornerScaling = True
's1.Fill.ApplyNoFill
' s1.Outline.SetPropertiesEx 0.003, OutlineStyles(0), CreateCMYKColor(0, 0, 0, 75), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=5#, Justification:=cdrOutlineJustificationMiddle
'Next
End Sub
Sub CopyText_Replace()
' Recorded 29/03/2016
' Ctrl + Numpad_9
ActiveDocument.Unit = cdrMillimeter
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
If OrigSelection.Shapes(1).Text.Story.Text = "AAAA" Then
OrigSelection.Shapes(1).Text.Story.Text = OrigSelection.Shapes(2).Text.Story.Text
OrigSelection.Shapes(1).Text.Story.ChangeCase cdrTextUpperCase
Else
OrigSelection.Shapes(1).Text.Replace "Abc", OrigSelection.Shapes(2).Text.Story.Text, True
End If
OrigSelection.Shapes(2).Selected = False
OrigSelection.Shapes(2).Delete
End Sub
Sub Num_Page()
Dim p As Page, s As Shape
For Each s In ActivePage.Shapes.FindShapes(, cdrTextShape)
If s.Text.Story.Font = "VNI-Avo" Then
s.Text.Story.Text = Right("00" & ActivePage.index - 2, 2)
End If
Next
End Sub
Sub check_range()
' Recorded 7/4/2015
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
For Each cC In ActiveDocument.Pages
If cC.Shapes.count <> 1 Then MsgBox cC.Name & " have " & cC.Shapes.count & " object", vbOKOnly, "Failed!"
'If cc.Shapes.All.SizeHeight <> 225 Or cc.Shapes.All.SizeWidth <> 150 Then
'cc.Activate
'MsgBox cc.Shapes.All.SizeHeight & vbCrLf & cc.Shapes.All.SizeWidth, vbOKOnly, cc.Name
'cc.Shapes.All.SizeHeight = 225
'cc.Shapes.All.SizeWidth = 150
'End If
Next cC
End Sub
Sub Edit_PageNumber()
Dim p As Page, s As Shape
For Each s In ActivePage.Shapes.FindShapes(, cdrTextShape)
If s.Text.Story.Font = "VNI-Avo" Then
s.Text.Story.Text = ActivePage.index - 2
End If
Next
End Sub
Public Function Arccos(x) As Double
If Round(x, 8) = 1# Then Arccos = 0#: Exit Function
If Round(x, 8) = -1# Then Arccos = PI: Exit Function
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function
Sub Macro11()
' Recorded 16/04/2016
Dim OrigSelection As ShapeRange
ActiveDocument.Unit = cdrMillimeter
Dim a, b, c As Double
Set OrigSelection = ActiveSelectionRange
a = OrigSelection.Shapes(1).Curve.Length
MsgBox a
b = OrigSelection.SizeWidth
c = OrigSelection.SizeHeight
End Sub
Sub Crop_to_A4()
' Recorded 23/04/2016
Dim OrigSelection As Shape
Set OrigSelection = ActiveSelectionRange.Shapes(1)
Dim s1 As Shape
Set s1 = ActiveLayer.CreateRectangle(0#, 11.680551, 8.26389, 0#)
s1.Rectangle.CornerType = cdrCornerTypeRound
s1.Rectangle.RelativeCornerScaling = True
s1.Fill.ApplyNoFill
s1.Outline.SetPropertiesEx 0.003, OutlineStyles(0), CreateCMYKColor(0, 0, 0, 100), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=5#, Justification:=cdrOutlineJustificationMiddle
Dim s2 As Shape
Set s2 = s1.Intersect(OrigSelection, True, True)
OrigSelection.Delete
s1.Delete
s2.OrderToFront
End Sub
Sub ssts()
ActiveDocument.ReferencePoint
MsgBox cdrMiddleLeft & vbCrLf & _
cdrMiddleRight & vbCrLf
End Sub
Sub watermark_remove()
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
For Each cC In ActiveDocument.Pages
'If cc.Layers("Layer 1").Shapes(1).SizeHeight < 150 Then cc.Layers("Layer 1").Shapes(1).Delete
If cC.Layers(2).Name = "Warning: Latest changes must be saved before extracting." Then cC.Layers(2).Delete
Next cC
End Sub
Sub page_trim()
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
Dim s1 As Shape
For Each cC In ActiveDocument.Pages
cC.Activate
cC.Shapes.All.Move 0#, 7#
s1 = ActiveDocument.MasterPage.DesktopLayer.Shapes(1).Trim(ActiveLayer.Shapes(1), True, True)
ActiveLayer.Shapes(2).Delete
Exit Sub
Next cC
End Sub
Sub cell_connect()
If ActiveSelection.Shapes.count <> 2 Then Exit Sub
Dim s1 As Shape
Dim s2 As Shape
Dim canh As Integer
Set s2 = ActiveSelection.Shapes(2)
If ActiveSelectionRange(2).SizeWidth < ActiveSelectionRange(2).SizeHeight Then
'MsgBox "1: " & ActiveSelectionRange(1).SizeWidth & vbCrLf & ActiveSelectionRange(1).SizeHeight
Set s1 = ActiveLayer.CreateRightAngleConnector(ActiveSelectionRange(2).SnapPoints.Object(cdrObjectPointBottom), ActiveSelectionRange(1).SnapPoints.Edge(4, 0.5))
Else
'MsgBox "2: " & ActiveSelectionRange(1).SizeWidth & vbCrLf & ActiveSelectionRange(1).SizeHeight
Set s1 = ActiveLayer.CreateRightAngleConnector(ActiveSelectionRange(2).SnapPoints.Object(cdrObjectPointRight), ActiveSelectionRange(1).SnapPoints.Edge(4, 0.5))
End If
s2.CreateSelection
End Sub
Sub Macro9()
' Recorded 14/07/2016
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim s1 As Shape
Set s1 = ActiveLayer.CreateRightAngleConnector(OrigSelection(2).SnapPoints.Object(cdrObjectPointLeft), OrigSelection(1).SnapPoints.Edge(2, 0.499995))
End Sub
Sub Macro10()
' Recorded 14/07/2016
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim s1 As Shape
Set s1 = ActiveLayer.CreateRightAngleConnector(OrigSelection(1).SnapPoints.Object(cdrObjectPointBottom), ActiveLayer.Shapes(3).SnapPoints.Edge(2, 0.499995))
End Sub
Sub Macro12()
' Recorded 14/07/2016
ActiveDocument.Unit = cdrMillimeter
Dim s As Shape
For Each s In ActivePage.Shapes
If s.Shapes(2).SizeWidth > 44 Then
s.Shapes(2).SizeWidth = 44
End If
s.Move 56.5 * InStrRev(s.Shapes(2).Text.Story.Text, vbTab), 0#
Next
End Sub
Sub Num_Page_2()
Dim p As Page, s As Shape
ActiveDocument.BeginCommandGroup "Page Number"
Dim cC As Page
For Each cC In ActiveDocument.Pages
cC.Activate
For Each s In ActivePage.Shapes.FindShapes(, cdrTextShape)
If s.Text.Story.Text = "01" Then
s.Text.Story.Text = Right("00" & ActivePage.index, 2)
End If
Next s
Next cC
ActiveDocument.EndCommandGroup
End Sub
Sub CenterPage()
' Recorded 31/08/2016
Dim p As Page, s As Shape
ActiveDocument.BeginCommandGroup "Page Center"
Dim cC As Page
For Each cC In ActiveDocument.Pages
cC.Activate
cC.Shapes.All.AlignAndDistribute 3, 3, 2, 0, False, 2
Next cC
ActiveDocument.EndCommandGroup
End Sub
Sub bb()
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection.SetOutlineProperties BehindFill:=cdrTrue, LineCaps:=cdrOutlineRoundLineCaps, LineJoin:=cdrOutlineRoundLineJoin
End Sub
Sub SizeCDNTNDT()
Dim p As Page, s As Shape
ActiveDocument.BeginCommandGroup "QDS"
Dim cC As Page
For Each cC In ActiveDocument.Pages
If cC.Shapes(1).Type = cdrTextShape Then
cC.Shapes(1).Text.Story.Size = 12
End If
Next
ActiveDocument.EndCommandGroup
End Sub
Public Sub Table()
Dim i As Integer
Dim t_row As Integer
Dim chon As ShapeRange
Set chon = ActiveSelectionRange
t_row = chon(1).Custom.rows.count
For i = 1 To 8
chon(1).Custom.Columns(i).Width = chon(2).Custom.Columns(i).Width
Next
For i = 1 To 8
chon(1).Custom.cell(i, 1).TextShape.Text.Story.Bold = True
chon(1).Custom.cell(i, 1).TextShape.Text.Story.Alignment = cdrCenterAlignment
chon(1).Custom.cell(i, t_row).TextShape.Text.Story.Bold = True
chon(1).Custom.cell(i, t_row).TextShape.Text.Story.Alignment = cdrCenterAlignment
Next
For i = 2 To t_row
chon(1).Custom.cell(1, i).TextShape.Text.Story.Alignment = cdrCenterAlignment
chon(1).Custom.cell(3, i).TextShape.Text.Story.Alignment = cdrCenterAlignment
chon(1).Custom.cell(4, i).TextShape.Text.Story.Alignment = cdrCenterAlignment
chon(1).Custom.cell(5, i).TextShape.Text.Story.Alignment = cdrCenterAlignment
chon(1).Custom.cell(6, i).TextShape.Text.Story.Alignment = cdrCenterAlignment
chon(1).Custom.cell(7, i).TextShape.Text.Story.Alignment = cdrRightAlignment
chon(1).Custom.cell(8, i).TextShape.Text.Story.Alignment = cdrRightAlignment
Next
For i = 1 To t_row
chon(1).Custom.rows(i).Height = chon(2).Custom.rows(i).Height
Next
'Dim t As Shape
't.Text.Story.Alignment = cdrRightAlignment
End Sub
Sub Num_Page_Dau_Thu_Y()
Dim p As Page, s As Shape, stt As Integer, tinh As String
tinh = InputBox("Ma tinh", "ma tinh")
stt = 1
For Each s In ActiveSelection.Shapes
s.Text.Story.Text = "MAÕ SOÁ: 40." & Right("00" & tinh, 2) & "." & Right("00" & stt, 2)
stt = stt + 1
Next
End Sub
Sub auto_number()
Optimization = True
ActiveDocument.BeginCommandGroup "Auto Number"
Dim p As Page, s As Shape, stt As Integer, tinh As String
stt = 1
For Each s In ActiveSelection.Shapes
s.Text.Story.Text = Right("000" & stt, 2)
stt = stt + 1
Next
ActiveDocument.EndCommandGroup
Optimization = False
Refresh
End Sub
Sub Macro14()
' Recorded 11/15/2016
ActiveLayer.Editable = False
End Sub
Sub text_Counter()
' Recorded 11/16/2016
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim st As String
Dim i As Integer
Dim html As String
st = CInt(InputBox("So bat dau", "STT cho danh sach"))
html = st
For i = st + 1 To st + 17
html = html & vbCrLf & i
Next
OrigSelection.Shapes(1).Text.Story.Text = html
End Sub
Public Function FindReplace(ByVal str As String, ByVal toFind As String, ByVal toReplace As String) As String
Dim i As Integer
For i = 1 To Len(str)
If Mid(str, i, Len(toFind)) = toFind Then ' does the string match?
FindReplace = FindReplace & toReplace ' add the new replacement to the final result
i = i + (Len(toFind) - 1) ' move to the character after the toFind
Else
FindReplace = FindReplace & Mid(str, i, 1) ' add a character
End If
Next i
End Function
Public Sub TextTranslate()
Dim huyen As Integer
Dim s As Shape
huyen = InputBox("Ma so huyen", "Huyen")
ActiveDocument.BeginCommandGroup "Text Translate" & Right("00" & huyen, 2)
For Each s In ActiveSelectionRange.Shapes
If s.Type = cdrTextShape Then
If s.Text.Story = "55." Then s.Text.Story = Right("00" & huyen, 2)
End If
Next s
ActiveDocument.EndCommandGroup
End Sub
Sub Copy_Header()
' Recorded 12/23/2016
Dim s1 As Shape
ActiveDocument.Unit = cdrMillimeter
If ActivePage.index Mod 2 = 0 Then
Set s1 = ActiveDocument.MasterPage.DesktopLayer.Shapes(1).Duplicate
s1.Move -200, 0#
Else
Set s1 = ActiveDocument.MasterPage.DesktopLayer.Shapes(2).Duplicate
s1.Move 200, 0#
End If
End Sub
Sub Page_number()
On Error Resume Next
Dim p As Page, s As Shape
ActiveDocument.BeginCommandGroup "SoTrang"
Dim cC As Page
For Each cC In ActiveDocument.Pages
cC.Activate
If ActiveLayer.Shapes(1).Shapes(1).Text.Story.Text = ActivePage.index Then
ActiveLayer.Shapes(1).Shapes(1).Text.Story.Size = 17
End If
'ActiveLayer.Shapes(1).Shapes(1).Text.Story.Text = ActivePage.Index
Next
ActiveDocument.EndCommandGroup
End Sub
Sub move_desktop_layer()
' Recorded 1/5/2017
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection.MoveToLayer
ActiveDocument.Pages(2).Activate
End Sub
Sub save_as_X7()
' Recorded 09/03/2017
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim SaveOptions As StructSaveAsOptions
Set SaveOptions = CreateStructSaveAsOptions
With SaveOptions
.EmbedVBAProject = True
.Filter = cdrCDR
.IncludeCMXData = False
.Range = cdrAllPages
.EmbedICCProfile = True
.Version = cdrVersion17
.KeepAppearance = True
End With
ActiveDocument.SaveAs "D:\GDVH 2001-29sss83.cdr", SaveOptions
MsgBox "Hello world"
End Sub
Sub groupLikeMeS()
ActiveDocument.BeginCommandGroup "ss"
Optimization = True
ActiveDocument.Unit = cdrMillimeter
Dim sr As Shapes
Set sr = ActivePage.Shapes.FindShapes(Query:="@outline = {1.5 mm} ").Shapes
sr.All.SetOutlineProperties Width:=4
Optimization = False
ActiveDocument.EndCommandGroup
Refresh
MsgBox "Group Finish"
End Sub
Sub RemoveTrans()
' Recorded 13/04/2017
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection(1).Shapes(2).Style.StringAssign "{""fill"":{""type"":""1"",""overprint"":""0"",""primaryColor"":""CMYK255,USER,0,0,255,0,100,cccd19cb-4675-4a5e-8bda-d0bbbaab8af0"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000""},""outline"":{""width"":""199"",""color"":""CMYK255,USER,255,0,255,0,100,cccd19cb-4675-4a5e-8bda-d0bbbaab8af0""},""transparency"":{""fill"":{""type"":""0"",""overprint"":""0"",""fillName"":null},""uniformTransparency"":""1"",""appliesTo"":""0""}}"
End Sub
Sub page_move()
ActiveDocument.BeginCommandGroup "Page Move"
Optimization = True
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
Dim s1 As Shape
For Each cC In ActiveDocument.Pages
cC.Activate
cC.Shapes.All.Move 0#, 0.5
Next cC
Optimization = False
ActiveDocument.EndCommandGroup
MsgBox "ok"
End Sub
Sub CreateA4_Border()
Attribute CreateA4_Border.VB_Description = "Tao Khung A4 cho trang"
' Recorded 10/05/2017
'
' Description:
' Tao Khung A4 cho trang
ActiveDocument.BeginCommandGroup "Page Border"
Optimization = True
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
Dim s1 As Shape
For Each cC In ActiveDocument.Pages
cC.Activate
Set s1 = ActiveLayer.CreateRectangle(0#, 210, 297, 0#)
s1.Rectangle.CornerType = cdrCornerTypeRound
s1.Rectangle.RelativeCornerScaling = True
s1.Fill.ApplyNoFill
s1.Outline.SetPropertiesEx 0.15, OutlineStyles(0), CreateCMYKColor(0, 0, 0, 80), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=45#, Justification:=cdrOutlineJustificationMiddle
Next cC
Optimization = False
ActiveDocument.EndCommandGroup
MsgBox "ok"
End Sub
Sub Import_eps()
' Recorded 18/05/2017
ActiveDocument.BeginCommandGroup "Page import"
Optimization = True
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
Dim s1 As Shape
Dim c As Integer
Dim impflt As ImportFilter
c = 1
For Each cC In ActiveDocument.Pages
cC.Activate
Set s1 = ActiveLayer.CreateRectangle(15.137795, 22.401579, 31.673224, 10.708661)
s1.Rectangle.CornerType = cdrCornerTypeRound
s1.Rectangle.RelativeCornerScaling = True
s1.Fill.ApplyNoFill
s1.Outline.SetPropertiesEx 0.003, OutlineStyles(0), CreateCMYKColor(0, 0, 0, 100), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=5#, Justification:=cdrOutlineJustificationMiddle
Dim impopt As StructImportOptions
Set impopt = CreateStructImportOptions
With impopt
.MaintainLayers = True
With .ColorConversionOptions
.SourceColorProfileList = "sRGB IEC61966-2.1,U.S. Web Coated (SWOP) v2,Dot Gain 20%"
.TargetColorProfileList = "sRGB IEC61966-2.1,U.S. Web Coated (SWOP) v2,Dot Gain 20%"
End With
End With
Set impflt = ActiveLayer.ImportEx("E:\Users\Desktop\so diem dong gay\Sach\Full" & c & ".eps", cdrPSInterpreted, impopt)
impflt.Finish
'Dim s2 As Shape
'Set s2 = ActiveShape
's2.Move 0.021146, 0.131917
c = c + 1
Next cC
Optimization = False
ActiveDocument.EndCommandGroup
MsgBox "ok"
End Sub
Sub HalfTone_bg()
' Recorded 8/21/2017
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection.ApplyUniformFill CreateCMYKColor(0, 0, 0, 20)
OrigSelection(1).Style.StringAssign "{""fill"":{""type"":""1"",""overprint"":""0"",""primaryColor"":""CMYK255,USER,0,0,0,51,100,cccd19cb-4675-4a5e-8bda-d0bbbaab8af0"",""screenSpec"":""0,0,45000000,60,0"",""winding"":""1""},""outline"":{""overprint"":""0"",""angle"":""0"",""screenSpec"":""0,0,45000000,60,0"",""behindFill"":""0"",""scaleWithObject"":""1"",""overlapArrow"":""0"",""shareArrow"":""0"",""endCaps"":""0"",""joinType"":""0"",""width"":""0"",""aspect"":""100"",""matrix"":""1,0,0,0,1,0"",""color"":""GRAY255,USER,0,100,00000000-0000-0000-0000-000000000000"",""dashDotSpec"":""0"",""leftArrow"":""|0"",""leftArrowAttributes"":""0|0|0|0|0|0|0"",""rightArrow"":""|0"",""rightArrowAttributes"":""0|0|0|0|0|0|0"",""dotLength"":""0"",""miterLimit"":""11.478339999999999"",""justification"":""0""},""transparency"":{""fill"":{""type""" & _
":""1"",""overprint"":""0"",""primaryColor"":""RGB255,USER,0,0,0,100,00000000-0000-0000-0000-000000000000"",""screenSpec"":""0,0,45000000,60,0""},""mode"":""0"",""uniformTransparency"":""0.3"",""startTransparency"":""0.5"",""endTransparency"":""0"",""appliesTo"":""2""}}"
Dim s1 As Shape
Set s1 = OrigSelection.ConvertToBitmapEx(5, False, True, 400, 1, True, False, 95)
s1.Selected = True
s1.Bitmap.ConvertToBW cdrRenderHalftone, 45, 90, cdrHalftoneRound, 135, 0
End Sub
Sub Mirror_PageNumber()
ActiveDocument.BeginCommandGroup "Page mirror"
Optimization = True
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim p As Page, s As Shape
Dim i As Integer
For i = 2 To ActiveDocument.Pages.count Step 2
ActiveDocument.Pages(i).Shapes(1).Move 32, 0#
Next
Optimization = False
ActiveDocument.EndCommandGroup
MsgBox "ok"
End Sub
Sub Macro16_web_img_import()
' Recorded 11/13/2017
Dim impopt As StructImportOptions
Set impopt = CreateStructImportOptions
With impopt
.Mode = cdrImportFull
.MaintainLayers = True
With .ColorConversionOptions
.SourceColorProfileList = "sRGB IEC61966-2.1,U.S. Web Coated (SWOP) v2,Dot Gain 20%"
.TargetColorProfileList = "sRGB IEC61966-2.1,U.S. Web Coated (SWOP) v2,Dot Gain 20%"
End With
End With
Dim impflt As ImportFilter
Set impflt = ActiveLayer.ImportEx("C:\Users\Hung\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\PGGE3WD5\staticmap[1]", cdrPNG, impopt)
impflt.Finish
Dim s1 As Shape
Set s1 = ActiveShape
ActivePage.Shapes.All.CreateSelection
ActiveSelection.Move 701.9581, 438.5907
End Sub
Sub Macro16()
' Recorded 11/13/2017
MsgBox ActiveDocument.SourceFileVersion
End Sub
Sub Add_giaykhen_2_bg()
' Recorded 11/16/2017
ActiveLayer.Paste
Dim Paste1 As ShapeRange
Set Paste1 = ActiveSelectionRange
Dim lr1 As Layer
Set lr1 = ActivePage.CreateLayer("bg")
lr1.Master = True
ActivePage.Layers("bg").Activate
lr1.Name = "bg"
Paste1.MoveToLayer ActiveLayer
ActiveLayer.Editable = False
End Sub
Sub Macro17_cmyk()
' Recorded 12/5/2017
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection(1).Bitmap.ConvertTo 5
ActiveLayer.Shapes(8).Bitmap.ConvertTo cdrCMYKColorImage
End Sub
Sub fttp()
' Fit text to path
Dim ot As ShapeRange
Dim ef As Effect
ActiveDocument.Unit = cdrMillimeter
Set ot = ActiveSelectionRange
Set ef = ot(2).Text.FitToPath(ot(1))
ef.TextOnPath.DistanceFromPath = 1.4
ef.TextOnPath.Offset = 4
End Sub
Sub page_move_1()
' Recorded 7/4/2015
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.ReferencePoint = cdrCenter
Dim cC As Page
For Each cC In ActiveDocument.Pages
cC.Shapes.All.Move 0#, -2
Next cC
End Sub
Sub change_tone()
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.BeginCommandGroup "Recolor"
Optimization = True
Dim x As Shape
Dim tmp As Integer
For Each x In ActiveSelectionRange.Shapes
If x.Fill.UniformColor.IsCMYK Then
tmp = x.Fill.UniformColor.CMYKBlack
x.Fill.UniformColor.CMYKMagenta = tmp
x.Fill.UniformColor.CMYKBlack = 0
End If
Next
Optimization = False
ActiveDocument.EndCommandGroup
ActiveWindow.Refresh
Application.Refresh
End Sub
Sub change_tone_2()
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.BeginCommandGroup "Recolor"
Optimization = True
Dim x As Shape
Dim tmp As Integer
For Each x In ActiveSelectionRange.Shapes
If x.Fill.UniformColor.IsCMYK Then
If x.Fill.UniformColor.CMYKCyan > 0 Then
tmp = x.Fill.UniformColor.CMYKBlack
x.Fill.UniformColor.CMYKMagenta = x.Fill.UniformColor.CMYKCyan
x.Fill.UniformColor.CMYKCyan = 0
End If
End If
Next
Optimization = False
ActiveDocument.EndCommandGroup
ActiveWindow.Refresh
Application.Refresh
End Sub
Sub resample1()
Dim sr As ShapeRange, p As Page, s As Shape
For Each p In ActiveDocument.Pages
p.Activate
Set sr = ActivePage.Shapes.FindShapes(, cdrBitmapShape)
For Each s In sr
s.Bitmap.Resample , , , 600, 600
Next s
'sr.Move 0, 0.4
Next p
End Sub
Sub resample2()
' ActiveSelection.Shapes(1).Bitmap.Resample , , , 300, 300
Call resample3
End Sub
Sub resample3(Optional d As Integer = 300)
'Giam do phan giai hinh anh qua 300dpi
'Resample big image resolution
ActiveDocument.BeginCommandGroup "Resample"
Optimization = True
Dim sr As ShapeRange, p As Page, s As Shape, t As Shape
For Each p In ActiveDocument.Pages
p.Activate
Set sr = ActivePage.Shapes.FindShapes(, cdrBitmapShape)
For Each s In sr
If s.Bitmap.ResolutionX > d Then
s.Bitmap.Crop
s.Bitmap.Resample , , , d, d
End If
Next s
For Each t In ActivePage.Shapes.FindShapes(Query:="[email protected]")
Set sr = t.PowerClip.Shapes.FindShapes(, cdrBitmapShape)
For Each s In sr
If s.Bitmap.ResolutionX > d Then
s.Bitmap.Crop
s.Bitmap.Resample , , , d, d
End If
Next s
Next t
Next p