AndrewPerl
04-20-2006, 07:35 AM
I have written the following code to format mainframe screen captures for our technical writers and business analysts.
Sub Format3270Screen()
'
' Format3270Screen Macro
' Macro created 4/19/2006 by dtxxxxx
Dim strTemp As String
'Is the last character of the selection a paragraph mark?
'If so, then move the selection back one character;
'This ensures that the screen capture will be formatted as a single paragraph
strTemp = Selection.Text
If Right(strTemp, 1) = vbCr Then Selection.MoveEnd _
Unit:=wdCharacter, Count:=-1
'Clear formatting parameters for Find and Replace options
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'Set parameters for Find and Replace
With Selection.Find
.Text = "^p"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'Execute the Find and Replace and apply "3270 Screen" style to selection
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Style = ActiveDocument.Styles("3270 Screen")
End Sub
The problem arises when the code executes the replace all. A dialog box appears stating, "Word has finished searching the selection. X replacements were made. Do you want to search the remainder of the document?" The user has a choice of selecting Yes or No. I want to be able to prevent the user from selecting Yes. Is this possible????
Andrew Perl
Kansas City
Sub Format3270Screen()
'
' Format3270Screen Macro
' Macro created 4/19/2006 by dtxxxxx
Dim strTemp As String
'Is the last character of the selection a paragraph mark?
'If so, then move the selection back one character;
'This ensures that the screen capture will be formatted as a single paragraph
strTemp = Selection.Text
If Right(strTemp, 1) = vbCr Then Selection.MoveEnd _
Unit:=wdCharacter, Count:=-1
'Clear formatting parameters for Find and Replace options
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'Set parameters for Find and Replace
With Selection.Find
.Text = "^p"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'Execute the Find and Replace and apply "3270 Screen" style to selection
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Style = ActiveDocument.Styles("3270 Screen")
End Sub
The problem arises when the code executes the replace all. A dialog box appears stating, "Word has finished searching the selection. X replacements were made. Do you want to search the remainder of the document?" The user has a choice of selecting Yes or No. I want to be able to prevent the user from selecting Yes. Is this possible????
Andrew Perl
Kansas City