Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-27-2014, 12:24 PM
Martin77 Martin77 is offline Macro not starting from other documents Windows 7 32bit Macro not starting from other documents Office 2013
Novice
Macro not starting from other documents
 
Join Date: Nov 2014
Posts: 2
Martin77 is on a distinguished road
Default Macro not starting from other documents

Hallo,

This Code

Code:
Private Sub document_contentcontrolonenter(ByVal ContentControl As ContentControl)
MsgBox "Hallo, I am " & ContentControl.Tag
End Sub
works within the template where it is stored.
When I click within the document the check box with the Tag "Martin"
the message comes with "Hallo, I am Martin"

Please see attached file.

The template is saved in
AppData\Roaming\Microsoft\Word\STARTUP

Any macros in any dotm-documents is this directory work with all documents.

This macro does not.

Why is that so?

How can I make it enable for all documents?

Best regards,


Martin
Attached Files
File Type: dotm Grauzone.dotm (17.5 KB, 10 views)
Reply With Quote
  #2  
Old 11-28-2014, 12:02 AM
gmayor's Avatar
gmayor gmayor is offline Macro not starting from other documents Windows 7 64bit Macro not starting from other documents Office 2010 32bit
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

The reason it doesn't work is that the macro is in the ThisDocument module, and 'ThisDocument' is the template itself, so it will only work for actions that relate to the template. Thus it works for the CC in the template body, but not for other documents.

See http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm which explains how to write application event procedures.
__________________
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
  #3  
Old 11-28-2014, 11:38 AM
Martin77 Martin77 is offline Macro not starting from other documents Windows 7 32bit Macro not starting from other documents Office 2013
Novice
Macro not starting from other documents
 
Join Date: Nov 2014
Posts: 2
Martin77 is on a distinguished road
Default

After reading your link and other sites, this seems too complicate for me, however it is an interesting topic.

Thank you for your help, gmayor.
Regards, Martin
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Word 2013 Documents open as full version documents on two computers sporadically Jaydenc-Fortress Word 2 08-07-2014 12:34 AM
Macro for find/replace (including headers and footers) for multiple documents jpb103 Word VBA 2 05-16-2014 04:59 AM
Macro not starting from other documents Excel stops responding after starting macro Catalin.B Excel Programming 2 09-07-2012 04:05 AM
Macro not starting from other documents merging documents in macro page no Rose_Garden Word 1 03-31-2012 04:50 AM
Macro not starting from other documents Starting Over zoeshaus Outlook 4 06-16-2010 12:20 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:32 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