Pogla
02-10-2010, 08:18 PM
Hey guys,
I have searched through these forums, but I cannot find exactly what I need (or I'm just being thick).
I am setting up a standard document in Word 2003 (for release management), and have put in a user form for the variables.
What I want to be able to do is show or hide some sections of text based on a checkbox value in the User Form.
The text to be shown/hidded has some formatting (one part has a header then normal text, another part has numbering).
I'm wondering weather I should put the text I want to add in a variable (in which case I need help with formatting), or put it into a field and have it hidden by default, and only unhidden when the checkbox is selected (in which case I need help with the code).
Also, I have coded the button to update the document from the form field, but I want to have another button to update just the DocVariable fields.
Code for updating all fields:
Private Sub UpdateButt_Click()
'Keep the cursor at the top of the page
Application.ScreenUpdating = False
'input variables
With ActiveDocument
.Variables("ContactNo").Value = ConNumTxt.Value
.Variables("Requestor").Value = RequestorTxt.Value
.Variables("DBname").Value = DBnameTxt.Value
.Variables("LinkedSrv").Value = LinkSrvTxt.Value
.Variables("ODBCsource").Value = ODBCsourceTxt.Value
.Variables("ODBCtarget").Value = ODBCtargetTxt.Value
.Variables("VerNum").Value = VerTxt.Value
.Variables("LinkVar").Value = "Not Applicable"
End With
ActiveDocument.Fields.Update
Application.ScreenUpdating = True
Unload Me
End Sub
I have searched through these forums, but I cannot find exactly what I need (or I'm just being thick).
I am setting up a standard document in Word 2003 (for release management), and have put in a user form for the variables.
What I want to be able to do is show or hide some sections of text based on a checkbox value in the User Form.
The text to be shown/hidded has some formatting (one part has a header then normal text, another part has numbering).
I'm wondering weather I should put the text I want to add in a variable (in which case I need help with formatting), or put it into a field and have it hidden by default, and only unhidden when the checkbox is selected (in which case I need help with the code).
Also, I have coded the button to update the document from the form field, but I want to have another button to update just the DocVariable fields.
Code for updating all fields:
Private Sub UpdateButt_Click()
'Keep the cursor at the top of the page
Application.ScreenUpdating = False
'input variables
With ActiveDocument
.Variables("ContactNo").Value = ConNumTxt.Value
.Variables("Requestor").Value = RequestorTxt.Value
.Variables("DBname").Value = DBnameTxt.Value
.Variables("LinkedSrv").Value = LinkSrvTxt.Value
.Variables("ODBCsource").Value = ODBCsourceTxt.Value
.Variables("ODBCtarget").Value = ODBCtargetTxt.Value
.Variables("VerNum").Value = VerTxt.Value
.Variables("LinkVar").Value = "Not Applicable"
End With
ActiveDocument.Fields.Update
Application.ScreenUpdating = True
Unload Me
End Sub