Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2023, 10:13 AM
TangInaMo TangInaMo is offline Create Userform - update fields and open specific template Windows 11 Create Userform - update fields and open specific template Office 2013
Novice
Create Userform - update fields and open specific template
 
Join Date: Oct 2023
Posts: 3
TangInaMo is on a distinguished road
Default Create Userform - update fields and open specific template


Hello everyone,

I am attempting to learn VBA through videos and reading multiple post but can't seem to figure out how to go about doing my project. Please bear with me any growing pains as I'm trying to learn and understand the logic.

I have multiple (4) templates with bookmarks created: (a) Contract number (b) Client Name (c) Effective date for each.

Templates are stored in my local drive.

I am attempting to create a userform to enter the data and select a specific template through a checkbox.

So far I've learned to create the userform to populate the fields to one template when the user enter the data but can't figure out how to populate each template and pull the specific template needed when the user selects a specific checkbox.

Please HELP!
Reply With Quote
  #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: 3,977
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
Reply



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 03:22 PM.


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