Go Back   Cyber Tech Help Support Forums > Software > Applications

Notices

Reply
 
Topic Tools
  #1  
Old July 27th, 2006, 03:02 PM
villa89 villa89 is offline
New Member
 
Join Date: May 2005
Posts: 11
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
Reply With Quote
  #2  
Old July 27th, 2006, 05:29 PM
z1p's Avatar
z1p z1p is offline
Cyber Tech Help Moderator
 
Join Date: Oct 2004
O/S: Windows Vista 64-bit
Location: Massachusetts
Posts: 5,258
Blog Entries: 1
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.
__________________
  • Please post back your results as they may help others.
  • See this sticky for the definitions of common networking terms.
  • Also, see this post for help with what to include when starting a thread in the networking forum.
  • If we have helped you, please consider supporting Cyber Tech Help with a subscription .
  • Chess anyone?


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']
Reply With Quote
  #3  
Old July 28th, 2006, 01:22 PM
villa89 villa89 is offline
New Member
 
Join Date: May 2005
Posts: 11
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
Reply With Quote
  #4  
Old July 28th, 2006, 03:00 PM
oracle128's Avatar
oracle128 oracle128 is offline
Α Ω
 
Join Date: Oct 2000
O/S: Windows XP Pro
Location: Melbourne, Australia
Age: 24
Posts: 9,401
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
Reply With Quote
  #5  
Old July 31st, 2006, 03:51 PM
villa89 villa89 is offline
New Member
 
Join Date: May 2005
Posts: 11
Gold! Thanks a million, I realise this probably aint the hardest code to write but I know next to nothing about macros,
Reply With Quote
Reply

Bookmarks

Topic Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:30 AM.

[ RSS ]