|
#1
|
|||
|
|||
|
Macro help [MS WORD]
Hi,
I am a total novice when its comes to writing macro's. I am trying to write one that I can use on lots of different word documents and finds a certain string e.g "Note number" and replaces it with another string "NOTE Number 12243". Can anyone tell me where to start or where I can ask for some source code? Thanks |
|
#2
|
||||
|
||||
|
Hi villa89,
I'm not strong in this area, but for something as simple as a macro to do a global replace you can use the record macro option. Save the macro in the normal.dot file and it will be available in all files that you open in word.
__________________
cmd /k ipconfig/all [use to start ipconfig from 'Run'] cmd /k ping <some website, like google or yahoo> [use to ping 'www.google.com' from 'Run'] |
|
#3
|
|||
|
|||
|
Hi,
Thnaks for the info, I was using the macro recoder but I wasn't using it right. Now that I have the first part right can anyone help me fix this code. I am trying to serch for a string ("fox") and then when/if I find that string in the document I want to replace the string ("XXX111" with "Recommendation"). Selection.Find.Execute Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting If Selection.Find .Text = "fox" = True .Forward = True .Wrap = wdFindAsk .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Then Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "XXX111" .Replacement.Text = "Recommendation" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End If |
|
#4
|
||||
|
||||
|
Code:
Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "fox" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With If Selection.Find.Execute = True Then Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "XXX111" .Replacement.Text = "Recommendation" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End If
__________________
Oracle's backup tutorial "A lot of people say games are addictive. Well, they're addictive in the sense that anything you like doing you repeat endlessly. But no one would say, 'Mr Kasparov, you have a chess problem,' or 'Tiger Woods, you have a golf addiction.'" - Ian Livingstone, Creative Director, Eidos. "A problem well stated is a problem half solved" - Charles Franklin Kettering |
|
#5
|
|||
|
|||
|
Gold! Thanks a million, I realise this probably aint the hardest code to write but I know next to nothing about macros,
|
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 11:30 AM.
[
RSS ]








