Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-19-2015, 09:04 AM
Unk Unk is offline VBA and Word basics help Windows 7 64bit VBA and Word basics help Office 2010 64bit
Novice
VBA and Word basics help
 
Join Date: Apr 2015
Posts: 3
Unk is on a distinguished road
Default VBA and Word basics help

I've created a document with a control (a drop-down menu) that changes the content of a second control depending on what the user selects in the first one. I created the code for this in VBA, but as it stands now it all vanishes when I close the document, and I have to enter the code again.



What I need in the end is to create a control that allows readers of the document to select one of three types, and have text input fields on the page below change according to the type selected. One of these input fields should be formatted as an ol/ ordered list/ numbered list, so when the user types and hits return, a new numbered line appears. The other two types can just be free text entry fields.

I've read all of this page, as well as all of the pages it links to:

https://msdn.microsoft.com/en-us/library/3hekt07s.aspx

but I'm still pretty much lost about how to even just save the document with the functionality that I've created so far. If someone could just walk me through some of the basics that would be a great help.

Here's the VBA code:

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
 If ContentControl.Tag = "TypeSelect" Then
  Debug.Print ContentControl.Range
  Select Case ContentControl.Range
    Case "Task"
      ActiveDocument.ContentControls(2).Range = "Enter Steps"
    Case "Concept"
      ActiveDocument.ContentControls(2).Range = "Enter Descriptive Content"
    Case Else
      ActiveDocument.ContentControls(2).Range = "Enter Reference Data"
       End Select
  End If
End Sub
This is in

Code:
Project (NameOfMyDocument)
  MicrosoftWordObjects
     ThisDocument
On the page I have two controls, and the first one controls what the other one displays-- until I close the whole thing and open it again, at which point the above code is gone. The above code changes one control as you exit another, whereas what I really need is a control that changes a text field and its formatting.

Thanks in advance
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 12:29 PM.


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