Problem with Macros

T

tom

I've recently switched from PC to Mac platform. I intensively use
databases, in this case FileMaker Pro 8.5 Advanced, to output text to
Word. In the past, I used Paradox to output tab-delimited text with
automatically inserted "markers" that allowed search-and-replace
editing. For example, I would insert characters such as £ before and
after field strings to allow a search-and-replace using wildcards. So
£?*£ allowed me to write a macro in Word to search for a text string
between those characters to change the formatting to bold, for example-
a very powerful editing tool.

On my new platform, I don't have any problem exporting from FileMaker.
The problem is in Word 2004 for Mac. My newly written macros work fine
on straight text searches, for example, replacing an asterisk with a
paragraph mark. However, in any instance in which I use wildcards in
the search and replace, the macros fail. As I record a macro,
everything happens as it should: the search shown above finds the text
string and changes it to bold. When I run the resulting recorded
macro, however, the search and replace fails: instead of replacing the
text string with bold formatting, it deletes the string entirely. This
is true in every case in which wildcards are involved.

Any advice?
 
T

tom

Post your code.

Thanks for your reply! Here is one segment of the code:


Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "£?*£"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
 
J

JE McGimpsey

Here is one segment of the code:


Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "£?*£"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

The reason your text is deleted is that you're telling Word to replace
the text within the pound signs (inclusive) with "". So that's exactly
what it's doing. Try this instead:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "£(?*)£"
.Replacement.Text = "\1"
.Replacement.Font.Bold = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

You can find more info on wildcards here:

http://word.mvps.org/faqs/general/UsingWildcards.htm

(If in Safari, you may need to hit refresh a couple of times).
 
T

tom

The reason your text is deleted is that you're telling Word to replace
the text within the pound signs (inclusive) with "". So that's exactly
what it's doing. Try this instead:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "£(?*)£"
.Replacement.Text = "\1"
.Replacement.Font.Bold = True
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

You can find more info on wildcards here:

http://word.mvps.org/faqs/general/UsingWildcards.htm

(If in Safari, you may need to hit refresh a couple of times).
 
T

tom

Thanks very much -- that worked fine. I also very much appreciate the
useful link. I'll be spending a lot of time there.

Best regards...
 
T

tom

Thanks very much for the help, and thanks also for the very useful
link.

Best regards...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top