Quotation Marks Macro

* * *

I've pasted my current Quotation Marks Macro below. It works great mostly. However, sometimes the German quotation marks in a text are a bit non-standard , and it will get stuck on these. Also, if the text within the quotations marks is too long it won't work. Another thing is that the Visual Basic (VB) code could be a bit confusing because I wrote it originally in Microsoft Word Basic - a precursor to VB. Microsoft converted this older code automatically to the latest version.

Description

Macro to replace German typographical quotation marks with standard English ones

For example: replace ,,Integrator Toolkit" with "Integrator Toolkit"

Useful when translating German texts to English.


German to English Quotation Marks Conversion Macro Code

' Sub Quotmarks_B()

'

' Quotmarks_B Makro

' Do English Quotation marks, mod: change style of quotation marks used 13.09.04

'

Rem Macro to replace typographical quotation marks with normal English ones

Rem Macro to replace "Integrator Toolkit" with "Integrator Toolkit"

Rem Mod 15.2.2000 New quotation marks changed to " & wrap =1

Rem Mod 26.11.01 Disable 'with pattern match' at end of macro

Rem Mod 13.09.04 Use new style quotatoion marks

Rem Mod 13.09.04 Insert check for (2nd) " in search string

Rem If found, output alarm and halt macro

' Error in this macro if l.c. and uppercase quotation marks

' are mixed in a text. The l.c. ones are done wrong!!

Public Sub MAIN()

Dim TempStr$

Dim n

Dim a$

Dim b$

WordBasic.StartOfDocument

Loop_:

WordBasic.CharLeft 1

WordBasic.EditFind Find:=Chr(132) + "*" + Chr(147), Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, Format:=0, Wrap:=1

If WordBasic.EditFindFound() = 0 Then

Rem "3,4" not found, exit

GoTo Allover:

End If

Rem Save "Integrator Toolkit"

TempStr$ = WordBasic.[Selection$]()

Rem Mod 13.09.04 Insert check for (2nd) " in search string

Rem If found, output alarm and halt macro

' Point to 2nd char in search string (after 2

I = 2

While I < Len(TempStr$)

' Get next char from search string

TempChr = Mid(TempStr$, I, 1)

LCQuotmark = Chr(132)

I = I + 1

If TempChr = LCQuotmark Then

' Error, (2nd) " in search string

GoTo Error:

End If

Wend

' OK, no (2nd) " in search string

Rem Get length of string

n = Len(TempStr$)

Rem Get contents of quotation marks, ie Integrator Toolkit

a$ = Mid(TempStr$, 2, n - 2)

Rem Form "Integrator Toolkit", ie with English quotation marks

' Mod, use new style quotation marks

b$ = Chr(147) + a$ + Chr(148)

Rem Replace "Integrator Toolkit" with "Integrator Toolkit"

WordBasic.CharLeft 1

WordBasic.EditReplace Find:=TempStr$, Replace:=b$, Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceOne:=1, Format:=0, Wrap:=2

Rem Loop for next "3,4"

WordBasic.CharLeft 1

GoTo Loop_

Error:

WordBasic.Beep

WordBasic.MsgBox "Quotation marks syntax error!"

Exit Sub

Allover:

WordBasic.StartOfDocument

Rem Disable 'with pattern match'

With Selection.Find

.MatchWildcards = False

End With

End Sub

Back to list of my macros

Like some details on the programmer?