Assume that I am working in Word 2010, and
I have two Word documents open, Doc1 and Doc2, and
I am editing Doc1.
Sometimes, when I am working in Doc1, and I click on the button that triggers the macro below "subCurlyQuots", the macro will operate on Doc2 instead of Doc1.
How can I make sure that the macro operates on Doc1 instead of Doc2?
Any help would be much appreciated.
Thanks,
Marc
Code:
Sub subCurlyQuots()
'
' CurlyQuotes Macro
'
'
ActiveDocument.ActiveWindow.SetFocus
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="CurlyQuotes99999999999999"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = """"
.Replacement.Text = """"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "'"
.Replacement.Text = "'"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.GoTo What:=wdGoToBookmark, Name:="CurlyQuotes99999999999999"
ActiveDocument.Bookmarks("CurlyQuotes99999999999999").Delete
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub ' subCurlyQuots()