Debian Codegraph @

texmf-dist/doc/latex/apa6/pseudoTeX/TeX2WordForapa6.bas

raw
1 %%
2 %% This is file `./pseudoTeX/TeX2WordForapa6.bas',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% apa6.dtx (with options: `bas')
8 %% ----------------------------------------------------------------------
9 %%
10 %% apa6 - A LaTeX class for formatting documents in compliance with the
11 %% American Psychological Association's Publication Manual, 6th edition
12 %%
13 %% Copyright (C) 2011-2023 by Brian D. Beitzel <brian at beitzel.com>
14 %%
15 %% This work may be distributed and/or modified under the
16 %% conditions of the LaTeX Project Public License (LPPL), either
17 %% version 1.3c of this license or (at your option) any later
18 %% version. The latest version of this license is in the file:
19 %%
20 %% http://www.latex-project.org/lppl.txt
21 %%
22 %% Users may freely modify these files without permission, as long as the
23 %% copyright line and this statement are maintained intact.
24 %%
25 %% This work is not endorsed by, affiliated with, or probably even known
26 %% by, the American Psychological Association.
27 %%
28 %% ----------------------------------------------------------------------
29 %%
30 Attribute VB_Name = "TeX2WordForapa6"
31 Sub FormatTex2WordDocument()
32
33 Dim strRunningHead, r, E
34 Dim myrange As Range
35
36 strRunningHead = InputBox("Please type the running head:", "Running Head")
37 If strRunningHead = "" Then Exit Sub
38
39 Selection.EndKey Unit:=wdStory
40 Selection.InsertBreak Type:=wdPageBreak
41 Selection.TypeText Text:="References" & vbCrLf
42 Selection.MoveUp Unit:=wdLine, Count:=1
43 Selection.ParagraphFormat.LeftIndent = InchesToPoints(0)
44 Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
45
46 Selection.HomeKey Unit:=wdStory
47
48 Call FormatTex2WordPageHeader(strRunningHead)
49 Call FormatAndMoveTex2WordTables
50 Call FormatAndMoveTex2WordFigures
51
52 Selection.EndKey Unit:=wdStory
53 Selection.InsertBreak Type:=wdPageBreak
54 Selection.TypeText Text:="Appendix" & vbCrLf
55 Selection.MoveUp Unit:=wdLine, Count:=1
56 Selection.ParagraphFormat.LeftIndent = InchesToPoints(0)
57 Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
58
59 ' touch up temporary citations
60 Selection.HomeKey Unit:=wdStory
61
62 Selection.Find.ClearFormatting
63 Selection.Find.Replacement.ClearFormatting
64 With Selection.Find
65 .Text = "{\"
66 .Replacement.Text = "{"
67 .Forward = True
68 .Wrap = wdFindContinue
69 .Format = False
70 .MatchCase = False
71 .MatchWholeWord = False
72 .MatchWildcards = False
73 .MatchSoundsLike = False
74 .MatchAllWordForms = False
75 End With
76 Selection.Find.Execute Replace:=wdReplaceAll
77
78 With Selection.Find
79 .Text = "@}"
80 .Replacement.Text = "}"
81 .Forward = True
82 .Wrap = wdFindContinue
83 .Format = False
84 .MatchCase = False
85 .MatchWholeWord = False
86 .MatchWildcards = False
87 .MatchSoundsLike = False
88 .MatchAllWordForms = False
89 End With
90 Selection.Find.Execute Replace:=wdReplaceAll
91
92 With Selection.Find
93 .Text = "{e.g.,\"
94 .Replacement.Text = "{e.g.`, \"
95 .Forward = True
96 .Wrap = wdFindContinue
97 .Format = False
98 .MatchCase = False
99 .MatchWholeWord = False
100 .MatchWildcards = False
101 .MatchSoundsLike = False
102 .MatchAllWordForms = False
103 End With
104 Selection.Find.Execute Replace:=wdReplaceAll
105
106 With Selection.Find
107 .Text = "{i.e.,\"
108 .Replacement.Text = "{i.e.`, \"
109 .Forward = True
110 .Wrap = wdFindContinue
111 .Format = False
112 .MatchCase = False
113 .MatchWholeWord = False
114 .MatchWildcards = False
115 .MatchSoundsLike = False
116 .MatchAllWordForms = False
117 End With
118 Selection.Find.Execute Replace:=wdReplaceAll
119
120 With Selection.Find
121 .Text = "{cf.\"
122 .Replacement.Text = "{cf. \"
123 .Forward = True
124 .Wrap = wdFindContinue
125 .Format = False
126 .MatchCase = False
127 .MatchWholeWord = False
128 .MatchWildcards = False
129 .MatchSoundsLike = False
130 .MatchAllWordForms = False
131 End With
132 Selection.Find.Execute Replace:=wdReplaceAll
133
134 With Selection.Find
135 .Text = "@p. "
136 .Replacement.Text = "@"
137 .Forward = True
138 .Wrap = wdFindContinue
139 .Format = False
140 .MatchCase = False
141 .MatchWholeWord = False
142 .MatchWildcards = False
143 .MatchSoundsLike = False
144 .MatchAllWordForms = False
145 End With
146 Selection.Find.Execute Replace:=wdReplaceAll
147
148 With Selection.Find
149 .Text = "@pp. "
150 .Replacement.Text = "@"
151 .Forward = True
152 .Wrap = wdFindContinue
153 .Format = False
154 .MatchCase = False
155 .MatchWholeWord = False
156 .MatchWildcards = False
157 .MatchSoundsLike = False
158 .MatchAllWordForms = False
159 End With
160 Selection.Find.Execute Replace:=wdReplaceAll
161
162 ' for table footnotes
163 With Selection.Find
164 .Text = "[para,flushleft] "
165 .Replacement.Text = ""
166 .Forward = True
167 .Wrap = wdFindContinue
168 .Format = False
169 .MatchCase = False
170 .MatchWholeWord = False
171 .MatchWildcards = False
172 .MatchSoundsLike = False
173 .MatchAllWordForms = False
174 End With
175 Selection.Find.Execute Replace:=wdReplaceAll
176
177 ' remove extra spaces at the end of paragraphs
178 With Selection.Find
179 .Text = " ^p"
180 .Replacement.Text = "^p"
181 .Forward = True
182 .Wrap = wdFindContinue
183 .Format = False
184 .MatchCase = False
185 .MatchWholeWord = False
186 .MatchWildcards = False
187 .MatchSoundsLike = False
188 .MatchAllWordForms = False
189 End With
190 Selection.Find.Execute Replace:=wdReplaceAll
191
192 ' delete the instructions
193 Selection.HomeKey Unit:=wdStory
194
195 Set myrange = Selection.Range
196 myrange.Start = Selection.Start
197
198 Selection.HomeKey Unit:=wdStory
199 Selection.Find.ClearFormatting
200 With Selection.Find
201 .Execute findText:="Delete these instructions!", Forward:=True, Wrap:=wdFindStop
202 myrange.End = Selection.End + 1
203 myrange.Select
204 myrange.Delete
205 End With
206
207 Selection.HomeKey Unit:=wdStory
208
209 End Sub
210
211 Sub FormatTex2WordPageHeader(strRunningHead)
212
213 Dim r, E
214
215 ' set the first page to be a different header
216 ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
217
218 With ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage)
219 .Range.ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
220 .Range.ParagraphFormat.FirstLineIndent = InchesToPoints(0)
221 .Range.ParagraphFormat.TabStops.ClearAll
222 .Range.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.5), _
223 Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
224 .Range.Text = "Running head: " & UCase(strRunningHead) & vbTab
225 With .Range.Font
226 .Name = "Times New Roman"
227 .Size = 12
228 .Bold = False
229 .Italic = False
230 End With
231
232 Set r = .Range
233 E = .Range.End
234 r.Start = E
235 .Range.Fields.Add r, wdFieldPage
236
237 End With
238
239 With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
240 .Range.ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
241 .Range.ParagraphFormat.FirstLineIndent = InchesToPoints(0)
242 .Range.Text = UCase(strRunningHead)
243 .PageNumbers.Add PageNumberAlignment:=wdAlignPageNumberRight
244 With .Range.Font
245 .Name = "Times New Roman"
246 .Size = 12
247 .Bold = False
248 .Italic = False
249 End With
250 End With
251
252 End Sub
253
254 Sub FormatAndMoveTex2WordTables()
255
256 Dim i, rngParagraphs As Range
257
258 If ActiveDocument.Tables.Count > 0 Then
259
260 For i = 1 To ActiveDocument.Tables.Count
261
262 Selection.HomeKey Unit:=wdStory
263
264 Set rngParagraphs = ActiveDocument.Range( _
265 Start:=ActiveDocument.Tables(1).Range.Start, _
266 End:=ActiveDocument.Tables(1).Range.End)
267 rngParagraphs.Select
268
269 With Selection.Tables(1)
270 .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
271 .Borders(wdBorderRight).LineStyle = wdLineStyleNone
272 With .Borders(wdBorderTop)
273 .LineStyle = wdLineStyleSingle
274 .LineWidth = wdLineWidth050pt
275 .Color = wdColorAutomatic
276 End With
277 With .Borders(wdBorderBottom)
278 .LineStyle = wdLineStyleSingle
279 .LineWidth = wdLineWidth050pt
280 .Color = wdColorAutomatic
281 End With
282 .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
283 .Borders(wdBorderVertical).LineStyle = wdLineStyleNone
284 .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
285 .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
286 .Borders.Shadow = False
287 '.Rows.Alignment = wdAlignRowLeft
288 .PreferredWidthType = wdPreferredWidthPercent
289 .PreferredWidth = 100
290 .TopPadding = InchesToPoints(0.08)
291 .BottomPadding = InchesToPoints(0.08)
292 .LeftPadding = InchesToPoints(0.08)
293 .RightPadding = InchesToPoints(0.08)
294 .Spacing = 0
295 .AllowPageBreaks = True
296 .AllowAutoFit = False
297 End With
298
299 With Selection.ParagraphFormat
300 .LineSpacingRule = wdLineSpaceSingle
301 .LeftIndent = InchesToPoints(0)
302 .RightIndent = InchesToPoints(0)
303 .SpaceBefore = 0
304 .SpaceBeforeAuto = False
305 .SpaceAfter = 0
306 .SpaceAfterAuto = False
307 .WidowControl = False
308 .KeepWithNext = False
309 .KeepTogether = False
310 .PageBreakBefore = False
311 .NoLineNumber = False
312 .Hyphenation = True
313 .FirstLineIndent = InchesToPoints(0)
314 .CharacterUnitLeftIndent = 0
315 .CharacterUnitRightIndent = 0
316 .CharacterUnitFirstLineIndent = 0
317 .LineUnitBefore = 0
318 .LineUnitAfter = 0
319 .MirrorIndents = False
320 .TextboxTightWrap = wdTightNone
321 End With
322
323 rngParagraphs.Cut
324
325 Selection.EndKey Unit:=wdStory
326 Selection.InsertBreak Type:=wdPageBreak
327 Selection.TypeText Text:="Table " & i & vbCrLf
328 Selection.Paste
329
330 Next
331
332 End If
333
334 End Sub
335
336 Sub FormatAndMoveTex2WordFigures()
337
338 Dim i, rngParagraphs As Range
339
340 If ActiveDocument.InlineShapes.Count > 0 Then
341
342 For i = 1 To ActiveDocument.InlineShapes.Count
343
344 Selection.HomeKey Unit:=wdStory
345
346 Set rngParagraphs = ActiveDocument.Range( _
347 Start:=ActiveDocument.InlineShapes(1).Range.Start, _
348 End:=ActiveDocument.InlineShapes(1).Range.End)
349 rngParagraphs.Select
350 rngParagraphs.Cut
351
352 Selection.EndKey Unit:=wdStory
353 Selection.InsertBreak Type:=wdPageBreak
354 Selection.Paste
355 Selection.TypeText Text:=vbCrLf & "Figure " & i & vbCrLf
356
357 Next
358
359 End If
360
361 End Sub
362 %%
363 %% Copyright (C) 2011-2023 by Brian D. Beitzel <brian at beitzel.com>
364 %%
365 %% This work may be distributed and/or modified under the
366 %% conditions of the LaTeX Project Public License (LPPL), either
367 %% version 1.3c of this license or (at your option) any later
368 %% version. The latest version of this license is in the file:
369 %%
370 %% http://www.latex-project.org/lppl.txt
371 %%
372 %% Users may freely modify these files without permission, as long as the
373 %% copyright line and this statement are maintained intact.
374 %%
375 %% This work is not endorsed by, affiliated with, or probably even known
376 %% by, the American Psychological Association.
377 %%
378 %% This work is "maintained" (as per LPPL maintenance status) by
379 %% Brian D. Beitzel.
380 %%
381 %% This work consists of the file apa6.dtx
382 %% and the derived files apa6.ins,
383 %% apa6.cls,
384 %% apa6.pdf,
385 %% README,
386 %% APAamerican.txt,
387 %% APAbritish.txt,
388 %% APAdutch.txt,
389 %% APAenglish.txt,
390 %% APAgerman.txt,
391 %% APAngerman.txt,
392 %% APAgreek.txt,
393 %% APAczech.txt,
394 %% APAturkish.txt,
395 %% APAendfloat.cfg,
396 %% apa6.ptex,
397 %% TeX2WordForapa6.bas,
398 %% Figure1.pdf,
399 %% shortsample.tex,
400 %% longsample.tex, and
401 %% bibliography.bib.
402 %%
403 %%
404 %% End of file `./pseudoTeX/TeX2WordForapa6.bas'.