Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2015, 08:27 AM
DocTeam10 DocTeam10 is offline UserForm to Add XML Mapped Content Controls Windows 7 64bit UserForm to Add XML Mapped Content Controls Office 2013
Novice
UserForm to Add XML Mapped Content Controls
 
Join Date: Oct 2015
Location: Massachusetts, USA
Posts: 1
DocTeam10 is on a distinguished road
Default UserForm to Add XML Mapped Content Controls

Hey Everybody - I'm hoping that someone here can tell me what I'm doing wrong. I'm a complete newb with XML, and I'm having a hard time with a UserForm.

Thanks in advance for taking a look!!!



I'm working on a UserForm that does a few things
  • Adds a content control, either plain text or drop-down list based on selection
  • Updates the content control Title and Tag properties
  • Sets the placeholder text
  • Sets the XML Mapping

I have a macro that does this for specific things, Client and Vendor. So that info, and the XML paths are in the code. But I want to take input from the User form to create the XML path. I can get everything but that last bullet to work.

This is the code I have so far:

Code:
Option Explicit
    Dim strField As String
    Dim strPlace As String
    Dim strXML As String
    Dim strType As String

Private Sub UserForm_Initialize()
    txtPlace.Value = "<< >>"
    txtXML.Value = "/root/"
    
    With cmbType
        .AddItem "Plain Text"
        .AddItem "Drop-Down"
    End With
End Sub

Private Sub cmdOK_Click()
    XMLField.Hide
   


'define strType
    If cmbType.Value = "Plain Text" _
        Then strType = "Plain"
    If cmbType.Value = "Drop-Down" _
        Then strType = "List"
'define other strings
    strField = txtField.Value
    strPlace = txtPlace.Value
    strXML = txtXML.Value

'add content control

With Selection.Range
    If strType = "Plain" _
        Then .ContentControls.Add (wdContentControlText)
    If strType = "List" _
        Then .ContentControls.Add (wdContentControlDropdownList)

End With
    Selection.ParentContentControl.Title = strField
    Selection.ParentContentControl.Tag = strField
    Selection.ParentContentControl.XMLMapping.SetMapping xPath:=strXML
    Selection.ParentContentControl.SetPlaceholderText Text:=strPlace

End Sub
Reply With Quote
Reply

Tags
content control, userform, xml



Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm to Add XML Mapped Content Controls VBA to set Content controls as non printing Sammie0Sue Word VBA 21 01-12-2021 04:44 PM
VBA for content controls ciresuark Word VBA 1 03-10-2015 03:14 PM
Calculate Age From Content Controls kintap Word VBA 10 07-02-2014 09:25 AM
UserForm to Add XML Mapped Content Controls Content Controls Sammie0Sue Word 6 11-06-2013 10:56 PM
UserForm to Add XML Mapped Content Controls Grouping Content Controls cksm4 Word VBA 2 03-01-2011 12:46 PM

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