Hi all,
I work for myself and occasionally I hire one off consultants to assist when I get busy. I usually send them a copy of my templates to ensure they are consistent with my templates and fit on my letterhead etc.
I was wondering is it possible to write a macro which on opening the word document searches for a specific phrase (ie. the business name) and if this exists in the text of the document the macro ends.
If however the business name has been deleted and replaced by their own business name, I'd like the macro to search for my business name, not find it then delete everything, save the document and close the document.
Is something like this possible?
Any suggestions would be great.
Thanks for your help.
Hi again,
I've sorted it out. I used the following:
andPrivate Sub Document_Open() Selection.Find.ClearFormatting With Selection.Find .Text = "BUSINESS NAME" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchKashida = False .MatchDiacritics = False .MatchAlefHamza = False .MatchControl = False .MatchByte = False .CorrectHangulEndings = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = False .MatchFuzzy = False .Execute Selection.HomeKey Unit:=wdStory If Selection.Find.Found = False Then Call Delete End With End Sub
ThanksSelection.WholeStory Selection.Delete Unit:=wdCharacter, Count:=1 ActiveDocument.Save ActiveDocument.Close
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks