Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2015, 08:42 PM
fahmiakbar fahmiakbar is offline Code for storing new word Mac OS X Code for storing new word Office 2007
Novice
Code for storing new word
 
Join Date: Feb 2015
Posts: 2
fahmiakbar is on a distinguished road
Default Code for storing new word

Hi...
I'm learning new language and i want to store all my vocabularies in word office...
I need macro code that works like this :
1. first i copy a word from my ebook or other source, then by running a macro in my word office, it will search whether the coppied word has existed or not.
2. if existed, then highlight the word
3. if not existed then create new line after the lowermost word and paste the word.


I know how to do it by using keyboard shortcut, but it need more than one step and it cannot use conditional statement.
Thank
Reply With Quote
  #2  
Old 02-11-2015, 10:07 PM
macropod's Avatar
macropod macropod is offline Code for storing new word Windows 7 64bit Code for storing new word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use a macro like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrFnd As String
StrFnd = Trim(InputBox("Please input the word to find."))
If StrFnd = "" Then Exit Sub
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = StrFnd
    .Replacement.Text = "^&"
    .Format = True
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  If .Find.Found = True Then
    .Select
    '.HighlightColorIndex = wdYellow
  Else
    .InsertAfter vbCr & StrFnd
  End If
End With
Application.ScreenUpdating = True
End Sub
As coded, the macro merely selects the work if found. If you really do want to apply a highlight, uncomment the expression '.HighlightColorIndex = wdYellow'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-13-2015, 11:26 AM
fahmiakbar fahmiakbar is offline Code for storing new word Mac OS X Code for storing new word Office 2007
Novice
Code for storing new word
 
Join Date: Feb 2015
Posts: 2
fahmiakbar is on a distinguished road
Default

Hi macropod,

This is what i'm looking for and Thank for your great helping... this is working really well. Thank you so much for answering...
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code for storing new word Code to select the previous word capitala PowerPoint 1 12-11-2014 08:53 AM
Software that removes Word code ep2002 Word 6 10-10-2014 07:35 PM
PowerPoint storing colors as system color names ?!?! Malcom PowerPoint 0 08-24-2013 01:12 AM
Code for storing new word Add Google anylitics code to Word Doc Hexasphere Word 5 06-06-2011 02:15 AM
Styling 'code' in word scottyearl Word 0 03-08-2009 09:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:22 PM.


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