-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAminMacros.bas
137 lines (125 loc) · 3.92 KB
/
AminMacros.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
Attribute VB_Name = "AminMacros"
Sub MathType2Word()
Attribute MathType2Word.VB_ProcData.VB_Invoke_Func = "Normal.AminMacros.MathType2Word"
' By Amin Yahyaabadi
' MathType2Word Macro: to convert Mathtype Equations to Microsoft Word Equations
'
'
Application.Run MacroName:="MathTypeCommands.UILib.MTCommand_TeXToggle"
Dim found As Boolean
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(\\\[)(*)(\\\])"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
found = Selection.Find.Execute(Replace:=wdReplaceOne)
If found Then
Selection.Cut
Selection.OMaths.Add Range:=Selection.Range
Selection.paste
Selection.OMaths.BuildUp
End If
With Selection.Find
.ClearFormatting
.Text = "$*$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Cut
Selection.OMaths.Add Range:=Selection.Range
Selection.paste
Selection.OMaths.BuildUp
End Sub
Sub codePaste()
Attribute codePaste.VB_ProcData.VB_Invoke_Func = "Normal.AminMacros.codePaste"
' By Amin Yahyaabadi
' codePaste Macro: to paste a code snippet into MS word and make its background gray
'
'
Dim oRng As Word.Range
Set oRng = Selection.Range
oRng.paste
oRng.Select
With Selection.ParagraphFormat
With .Shading
.Texture = wdTexture5Percent
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorWhite
End With
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.CollapsedByDefault = False
.ReadingOrder = wdReadingOrderLtr
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
Selection.Font.Name = "CMU Typewriter Text"
End Sub
Sub pasteSelected()
'
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Set oRng = Selection.Range
oRng.paste
oRng.Select
End Sub