Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-02-2019, 06:10 PM
Visor Visor is offline Block Replace Windows 10 Block Replace Office 2013
Advanced Beginner
Block Replace
 
Join Date: Aug 2019
Posts: 38
Visor is on a distinguished road
Default Block Replace

Greetings friends of the forum.
I have macros to avoid copying, paste in my template.

In the attempt to prevent a student from copying and pasting information from other documents, I now need to avoid using the replace option as I have verified that it is possible to copy and replace in the template I am preparing
The replace code is this:


HTML Code:
Sub Replace()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "s"
        .Replacement.Text = _
            "Possible paragraph with what will be replaced, assuming you will put a letter s to find and replace it"
        .Forward = True
    End With
    Selection.Find.Execute
    With Selection
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseStart
        Else
            .Collapse Direction:=wdCollapseEnd
        End If
        .Find.Execute Replace:=wdReplaceOne
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseEnd
        Else
            .Collapse Direction:=wdCollapseStart
        End If
        .Find.Execute
    End With
End Sub
What would be the code to block the use of the replace option?
I appreciate your support in advance
Reply With Quote
  #2  
Old 09-03-2019, 03:02 PM
macropod's Avatar
macropod macropod is offline Block Replace Windows 7 64bit Block Replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Rather pointless endeavour, IMHO, especially since other methods can be used to replicate content without the need for copying & pasting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-04-2019, 06:48 AM
Visor Visor is offline Block Replace Windows 10 Block Replace Office 2013
Advanced Beginner
Block Replace
 
Join Date: Aug 2019
Posts: 38
Visor is on a distinguished road
Default

Thank you macropod for your answer, .. but for the issue raised ... are you sure there is no way with vba to block the function replace ??
Reply With Quote
  #4  
Old 09-04-2019, 03:16 PM
macropod's Avatar
macropod macropod is offline Block Replace Windows 7 64bit Block Replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

A macro to disable the Find function can be as simple as:
Code:
Sub EditReplace()
MsgBox "Go away!": Exit Sub
End Sub
Disabling macros when the document is opened can easily circumvent that. And, as I already said, there are other methods can be used to replicate content without the need for copying & pasting. For example, using an INCLUDETEXT field, then unlinking it, or using another macro that bypasses the user interface.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-05-2019, 04:03 AM
Visor Visor is offline Block Replace Windows 10 Block Replace Office 2013
Advanced Beginner
Block Replace
 
Join Date: Aug 2019
Posts: 38
Visor is on a distinguished road
Default

Thanks you macropod for the code, this one works perfect !!!
Reply With Quote
Reply

Tags
vba find and replace



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a block text and when click on the title of block hide and unhide the block labasritas@free.fr Word 4 09-17-2017 01:17 PM
More than one sum in a block Verusha Singh Excel 1 11-15-2016 12:45 AM
What is this block of text? nyempire Word 5 05-26-2016 06:08 AM
VBA Word - Building Block (AutoText) - Array - Replace Text with Specific Building Blocks jc491 Word VBA 7 01-03-2016 10:34 PM
Block Replace Block a page HMS Word 2 07-12-2013 04:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:57 AM.


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