473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Disable user interaction in a MS Word Macro

3
I have a macro in MS Word that does several hundred find and replace statements. The problem is each time it does a find and replace it prompts me do you want to search from the begining. How do I write into the code to not prompt me each time it does a correction. Below is a small piece of the code. Thanks

Sub Macro2()
'
' Macro2 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Paragraph"
.Replacement.Text = "PARA"
.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 = "period"
.Replacement.Text = "PD"
.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 = "jump"
.Replacement.Text = "JP"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Jan 4 '10 #1
1 4767
Guido Geurs
767 Expert 512MB
dear,

I think the WRAP must be excluded from the code or set to wdFindStop.

The help in VBA is:

Wrap Property
See AlsoApplies ToExampleSpecificsReturns or sets what happens if the search begins at a point other than the beginning of the document and the end of the document is reached (or vice versa if Forward is set to False) or if the search text isn't found in the specified selection or range. Read/write WdFindWrap.

WdFindWrap can be one of these WdFindWrap constants.
wdFindAsk After searching the selection or range, Word displays a message asking whether to search the remainder of the document.
wdFindContinue The find operation continues when the beginning or end of the search range is reached.
wdFindStop The find operation ends when the beginning or end of the search range is reached.

expression.Wrap
expression Required. An expression that returns a Find object.

Example
The following example searches forward through the document for the word "aspirin." When the end of the document is reached, the search continues at the beginning of the document. If the word "aspirin" is found, it's selected.

Expand|Select|Wrap|Line Numbers
  1. Sub WordFind()
  2.     With Selection.Find
  3.         .Forward = True
  4.         .ClearFormatting
  5.         .MatchWholeWord = True
  6.         .MatchCase = False
  7.         .Wrap = wdFindContinue
  8.         .Execute FindText:="aspirin"
  9.     End With
  10. End Sub
br,
Jan 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: bonehead | last post by:
Okay, here's a question I should have posted a very very long time ago. I'd like to prevent the user from being able to bypass certain error handling and updating functions that are programmed into...
3
by: zlst | last post by:
Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability....
3
by: Martin Austin | last post by:
Here's my problem. I'm launching an MS Word object on a Notes document Postopen event. The script kicks off a macro that saves the Word document to a temporary file every n minutes (backup of key...
1
by: Troy | last post by:
How do I answer the disable macro prompt automatically when opening an Excel workbook? We are using Excel 97 and 2002. In 2002 we want the Medium security (prompt user) to safeguard against e-mail...
5
by: Mason | last post by:
I'm having some problems converting VBA for Word 2000 to code that VB.Net understands. I recorded a macro in Word to add numbering (a. b. c.) to my paragraphs. I managed to translate quite a bit...
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
9
by: JBuckner | last post by:
My macro uses the Send Object (VBA Item.Send) function to email a spreadsheet to an Outlook contact list. I want the function to be completely automatic but Outlook displays a security warning...
6
by: yxq | last post by:
Hello, How to disable the UAC function in Vista using API? Thank you
7
by: devecibasi | last post by:
Hi all, I have a macro that executes ~200 queries which modify the data, create some tables etc. The macro runs when the user clicks a button on a form. I would like the queries to be invisible...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.