Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-31-2012, 05:55 PM
marceepoo marceepoo is offline Ensure macro operates in the right doc window Windows 7 64bit Ensure macro operates in the right doc window Office 2010 64bit
Novice
Ensure macro operates in the right doc window
 
Join Date: Sep 2012
Posts: 22
marceepoo is on a distinguished road
Default Ensure macro operates in the right doc window

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()

Last edited by macropod; 10-31-2012 at 08:54 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ensure macro operates in the right doc window Research window that won't go away. kaetsdz Word 3 08-08-2012 07:24 PM
Ensure macro operates in the right doc window ensure I have an 8.5x11 sheet Taylor Word 3 10-09-2011 12:39 AM
Ensure macro operates in the right doc window Problem with window Zakhary Word 1 05-22-2011 01:24 PM
Date pop-up window Roshan Hanief Word 0 04-23-2011 04:16 AM
Ensure macro operates in the right doc window How to ensure that each line ends only at the margin sparemejava Word 9 02-06-2011 03:21 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:57 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft