Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 01-25-2021, 05:47 AM
gmayor's Avatar
gmayor gmayor is offline Set Macro so it runs when other open the Word Document Windows 10 Set Macro so it runs when other open the Word Document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

In order to run when the document is opened, the macro needs to be renamed AutoOpen and the document should be saved as macro enabled. However you cannot force the user to run the macro.

Code:
Sub AutoOpen()
Const strPassword As String = "password"
    With ActiveDocument
        If Not .ProtectionType = wdNoProtection Then
            .Unprotect Password:=strPassword
        End If
        .Revisions.AcceptAll
        .Protect Password:=strPassword, _
                 NoReset:=False, _
                 Type:=wdAllowOnlyReading, _
                 UseIRM:=False, _
                 EnforceStyleLock:=False
    End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
macro assign word



Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Macro so it runs when other open the Word Document MS WORD search macro slows way down as it runs Chopper Word VBA 8 12-21-2020 03:49 PM
[Word VBA macro] How to open the website [languagetool.org] and check my Word document? citroen Word VBA 0 10-25-2020 05:07 AM
Set Macro so it runs when other open the Word Document Creating a macro from a non-saved Word doc that duplicates the current open document and saves it mike0215 Word VBA 3 11-17-2017 01:40 PM
Set Macro so it runs when other open the Word Document Macro to Open to a Website When No Document Is Open lostinwebspace Word VBA 1 02-13-2016 10:28 AM
VB code from one document runs on other open documents beav_35 Word VBA 0 11-10-2010 02:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:23 PM.


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