Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-20-2023, 08:08 PM
Guessed's Avatar
Guessed Guessed is offline Create Userform - update fields and open specific template Windows 10 Create Userform - update fields and open specific template Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

There is a better way to do this - put mapped Content Controls in the document where you want that data to be displayed. You can then either read or write to the first instance of each CC in the document to interact with the vba userform.

There are quite elegant templates to help with content controls (created by Greg Maxey and Graham Mayor which can be very useful if you are struggling with some of the concepts.

If you add a few content controls to your first template and set them to be mapped to built-in properties then you can paste these into the other templates at the relevant locations. You can then include code to read/write to the CCs OR to the document properties. eg
Code:
Sub DocProps()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.ContentControls
    aCC.Range.Text = aCC.Title
    If aCC.XMLMapping.IsMapped Then
      aCC.Tag = aCC.XMLMapping.XPath
    End If
  Next aCC
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a document based on a template, the page numbers in the TOC won't update billy8b8 Word 2 10-04-2015 06:06 AM
Create Userform - update fields and open specific template Create a Userform in Outlook to select a macro for an email template. snickerbart Outlook 4 04-17-2015 12:55 PM
Create scope-specific plans from Master Template BobbyG Project 3 04-08-2015 06:15 AM
Create Userform - update fields and open specific template How to create specific template AndyR PowerPoint 3 09-25-2014 06:05 PM
Does Word have an option to update fields AUTOMATICALLY at open??? Jamal NUMAN Word 17 01-27-2012 12:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:02 AM.


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