Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2021, 02:40 AM
LianaK LianaK 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 2010
Novice
Set Macro so it runs when other open the Word Document
 
Join Date: Jan 2021
Posts: 1
LianaK is on a distinguished road
Default Set Macro so it runs when other open the Word Document


Hi,

I have a very simple macro which works fine for me. The issue is that I can't seem to set it so that it operates when other people access the file which is really what I need. I would be grateful if any of you wise people can advise.

Image 1 shows where the macro is located(NewMacros). It's in Projects under the document template which I thought meant it would work, not normal.dotm.

Image 2 is the code I've used but I'm happy with that. I think it's something in the way I've got it set up but I've not been able to find out the issue despite many YouTube Videos and reading forums.

Thank you for your time,

L
Attached Images
File Type: png image001.png (18.9 KB, 14 views)
File Type: png image002.png (15.7 KB, 15 views)
Reply With Quote
  #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,103
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 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
Reply

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 07:09 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