This is what I need to do:

If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I want to
create a public variable called "incomplete" (would also want that
variable deleted if it already existed and TextBox1 were not blank when the
UserForm where unloaded). Then when I open UserForm4 if the variable
"incomplete" exists, I want the BackColor of CommandButton1 to be red.

Re: Creating a variable by Patrick

Patrick
Sun May 20 16:36:36 CDT 2007

I think I may have figured this out. I will be back if things do not work
out. Thanks

"Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
> This is what I need to do:
>
> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I want to
> create a public variable called "incomplete" (would also want that
> variable deleted if it already existed and TextBox1 were not blank when
> the UserForm where unloaded). Then when I open UserForm4 if the variable
> "incomplete" exists, I want the BackColor of CommandButton1 to be red.
>



Re: Creating a variable by Patrick

Patrick
Sun May 20 16:54:16 CDT 2007

My problem now is that having created the code below, if I access the
UserForm again I get an error because the variable all ready exists.



Private Sub CommandButton1_Click()

Unload UserForm1

Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
Me.OptionButton4)

If Title = False Then

ActiveDocument.Variables.Add Name:="Incomplete", Value:="True"

End If

End Sub





"Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
news:eywUzbymHHA.404@TK2MSFTNGP02.phx.gbl...
>I think I may have figured this out. I will be back if things do not work
>out. Thanks
>
> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
> news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
>> This is what I need to do:
>>
>> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I want
>> to create a public variable called "incomplete" (would also want that
>> variable deleted if it already existed and TextBox1 were not blank when
>> the UserForm where unloaded). Then when I open UserForm4 if the variable
>> "incomplete" exists, I want the BackColor of CommandButton1 to be red.
>>
>
>



Re: Creating a variable by Patrick

Patrick
Sun May 20 22:02:07 CDT 2007

This did the trick. If anyone has a better way though I am always ready to
learn.


Private Sub CommandButton1_Click()

Unload UserForm1

On Error GoTo Continue

ActiveDocument.Variables.Add Name:="Incomplete"

Continue:

Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
Me.OptionButton4)

If Title = False Then

ActiveDocument.Variables("Incomplete").Value = True

End If

End Sub


"Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
news:uEF8qlymHHA.1328@TK2MSFTNGP05.phx.gbl...
> My problem now is that having created the code below, if I access the
> UserForm again I get an error because the variable all ready exists.
>
>
>
> Private Sub CommandButton1_Click()
>
> Unload UserForm1
>
> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
> Me.OptionButton4)
>
> If Title = False Then
>
> ActiveDocument.Variables.Add Name:="Incomplete", Value:="True"
>
> End If
>
> End Sub
>
>
>
>
>
> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
> news:eywUzbymHHA.404@TK2MSFTNGP02.phx.gbl...
>>I think I may have figured this out. I will be back if things do not work
>>out. Thanks
>>
>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>> news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
>>> This is what I need to do:
>>>
>>> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I want
>>> to create a public variable called "incomplete" (would also want that
>>> variable deleted if it already existed and TextBox1 were not blank when
>>> the UserForm where unloaded). Then when I open UserForm4 if the variable
>>> "incomplete" exists, I want the BackColor of CommandButton1 to be red.
>>>
>>
>>
>
>



Re: Creating a variable by Doug

Doug
Sun May 20 22:45:06 CDT 2007

You do not have to specifically "Add" a document variable. Assigning a
value to it with

[document object].Variables("Varname").Value =

will cause it to be created with the assigned value if it does not exist, or
change the value assigned to it if it already exists.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
news:%23qMBtR1mHHA.4628@TK2MSFTNGP06.phx.gbl...
> This did the trick. If anyone has a better way though I am always ready to
> learn.
>
>
> Private Sub CommandButton1_Click()
>
> Unload UserForm1
>
> On Error GoTo Continue
>
> ActiveDocument.Variables.Add Name:="Incomplete"
>
> Continue:
>
> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
> Me.OptionButton4)
>
> If Title = False Then
>
> ActiveDocument.Variables("Incomplete").Value = True
>
> End If
>
> End Sub
>
>
> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
> news:uEF8qlymHHA.1328@TK2MSFTNGP05.phx.gbl...
>> My problem now is that having created the code below, if I access the
>> UserForm again I get an error because the variable all ready exists.
>>
>>
>>
>> Private Sub CommandButton1_Click()
>>
>> Unload UserForm1
>>
>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>> Me.OptionButton4)
>>
>> If Title = False Then
>>
>> ActiveDocument.Variables.Add Name:="Incomplete", Value:="True"
>>
>> End If
>>
>> End Sub
>>
>>
>>
>>
>>
>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>> news:eywUzbymHHA.404@TK2MSFTNGP02.phx.gbl...
>>>I think I may have figured this out. I will be back if things do not work
>>>out. Thanks
>>>
>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>> news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
>>>> This is what I need to do:
>>>>
>>>> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I want
>>>> to create a public variable called "incomplete" (would also want that
>>>> variable deleted if it already existed and TextBox1 were not blank when
>>>> the UserForm where unloaded). Then when I open UserForm4 if the
>>>> variable "incomplete" exists, I want the BackColor of CommandButton1 to
>>>> be red.
>>>>
>>>
>>>
>>
>>
>
>



Re: Creating a variable by Patrick

Patrick
Sun May 20 23:40:13 CDT 2007

Can anyone explain to me why the code below does not change the BackColor of
CommandButton1?

I added the "MsgBox ActiveDocument.Variables("Personal").Value" code just
so I could make sure the variable value was in fact "test".



Private Sub UserForm_Initialize()

MsgBox ActiveDocument.Variables("Personal").Value

If ActiveDocument.Variables("Personal").Value = "test" Then
CommandButton1.BackColor = &H8000000F
End If

End Sub







"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:uoWmyp1mHHA.3520@TK2MSFTNGP04.phx.gbl...
> You do not have to specifically "Add" a document variable. Assigning a
> value to it with
>
> [document object].Variables("Varname").Value =
>
> will cause it to be created with the assigned value if it does not exist,
> or change the value assigned to it if it already exists.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
> news:%23qMBtR1mHHA.4628@TK2MSFTNGP06.phx.gbl...
>> This did the trick. If anyone has a better way though I am always ready
>> to learn.
>>
>>
>> Private Sub CommandButton1_Click()
>>
>> Unload UserForm1
>>
>> On Error GoTo Continue
>>
>> ActiveDocument.Variables.Add Name:="Incomplete"
>>
>> Continue:
>>
>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>> Me.OptionButton4)
>>
>> If Title = False Then
>>
>> ActiveDocument.Variables("Incomplete").Value = True
>>
>> End If
>>
>> End Sub
>>
>>
>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>> news:uEF8qlymHHA.1328@TK2MSFTNGP05.phx.gbl...
>>> My problem now is that having created the code below, if I access the
>>> UserForm again I get an error because the variable all ready exists.
>>>
>>>
>>>
>>> Private Sub CommandButton1_Click()
>>>
>>> Unload UserForm1
>>>
>>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>>> Me.OptionButton4)
>>>
>>> If Title = False Then
>>>
>>> ActiveDocument.Variables.Add Name:="Incomplete", Value:="True"
>>>
>>> End If
>>>
>>> End Sub
>>>
>>>
>>>
>>>
>>>
>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>> news:eywUzbymHHA.404@TK2MSFTNGP02.phx.gbl...
>>>>I think I may have figured this out. I will be back if things do not
>>>>work out. Thanks
>>>>
>>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>>> news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
>>>>> This is what I need to do:
>>>>>
>>>>> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I
>>>>> want to create a public variable called "incomplete" (would also
>>>>> want that variable deleted if it already existed and TextBox1 were not
>>>>> blank when the UserForm where unloaded). Then when I open UserForm4 if
>>>>> the variable "incomplete" exists, I want the BackColor of
>>>>> CommandButton1 to be red.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: Creating a variable by Doug

Doug
Mon May 21 06:16:01 CDT 2007

I am not sure what, if any color is represented by &H8000000F

However, the following works:

If ActiveDocument.Variables("Personal").Value = "test" Then
CommandButton1.BackColor = wdColorRed
Else
CommandButton1.BackColor = wdColorGreen
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
news:%23lpWgI2mHHA.4240@TK2MSFTNGP02.phx.gbl...
> Can anyone explain to me why the code below does not change the BackColor
> of CommandButton1?
>
> I added the "MsgBox ActiveDocument.Variables("Personal").Value" code just
> so I could make sure the variable value was in fact "test".
>
>
>
> Private Sub UserForm_Initialize()
>
> MsgBox ActiveDocument.Variables("Personal").Value
>
> If ActiveDocument.Variables("Personal").Value = "test" Then
> CommandButton1.BackColor = &H8000000F
> End If
>
> End Sub
>
>
>
>
>
>
>
> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:uoWmyp1mHHA.3520@TK2MSFTNGP04.phx.gbl...
>> You do not have to specifically "Add" a document variable. Assigning a
>> value to it with
>>
>> [document object].Variables("Varname").Value =
>>
>> will cause it to be created with the assigned value if it does not exist,
>> or change the value assigned to it if it already exists.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>> news:%23qMBtR1mHHA.4628@TK2MSFTNGP06.phx.gbl...
>>> This did the trick. If anyone has a better way though I am always ready
>>> to learn.
>>>
>>>
>>> Private Sub CommandButton1_Click()
>>>
>>> Unload UserForm1
>>>
>>> On Error GoTo Continue
>>>
>>> ActiveDocument.Variables.Add Name:="Incomplete"
>>>
>>> Continue:
>>>
>>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>>> Me.OptionButton4)
>>>
>>> If Title = False Then
>>>
>>> ActiveDocument.Variables("Incomplete").Value = True
>>>
>>> End If
>>>
>>> End Sub
>>>
>>>
>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>> news:uEF8qlymHHA.1328@TK2MSFTNGP05.phx.gbl...
>>>> My problem now is that having created the code below, if I access the
>>>> UserForm again I get an error because the variable all ready exists.
>>>>
>>>>
>>>>
>>>> Private Sub CommandButton1_Click()
>>>>
>>>> Unload UserForm1
>>>>
>>>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>>>> Me.OptionButton4)
>>>>
>>>> If Title = False Then
>>>>
>>>> ActiveDocument.Variables.Add Name:="Incomplete", Value:="True"
>>>>
>>>> End If
>>>>
>>>> End Sub
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>>> news:eywUzbymHHA.404@TK2MSFTNGP02.phx.gbl...
>>>>>I think I may have figured this out. I will be back if things do not
>>>>>work out. Thanks
>>>>>
>>>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>>>> news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
>>>>>> This is what I need to do:
>>>>>>
>>>>>> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I
>>>>>> want to create a public variable called "incomplete" (would also
>>>>>> want that variable deleted if it already existed and TextBox1 were
>>>>>> not blank when the UserForm where unloaded). Then when I open
>>>>>> UserForm4 if the variable "incomplete" exists, I want the BackColor
>>>>>> of CommandButton1 to be red.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: Creating a variable by Tony

Tony
Mon May 21 08:37:24 CDT 2007

&H8000000F is the Windows system colour for 3-D Face. I'm not sure off the
top of my head exactly which elements this would apply to but command button
back colour wouldn't surprise me - and that would explain why setting it to
that value had no effect.

--
Enjoy,

Tony Jollans
Microsoft Word MVP

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:%23ZeAyl5mHHA.4848@TK2MSFTNGP05.phx.gbl...
>I am not sure what, if any color is represented by &H8000000F
>
> However, the following works:
>
> If ActiveDocument.Variables("Personal").Value = "test" Then
> CommandButton1.BackColor = wdColorRed
> Else
> CommandButton1.BackColor = wdColorGreen
> End If
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
> news:%23lpWgI2mHHA.4240@TK2MSFTNGP02.phx.gbl...
>> Can anyone explain to me why the code below does not change the BackColor
>> of CommandButton1?
>>
>> I added the "MsgBox ActiveDocument.Variables("Personal").Value" code
>> just so I could make sure the variable value was in fact "test".
>>
>>
>>
>> Private Sub UserForm_Initialize()
>>
>> MsgBox ActiveDocument.Variables("Personal").Value
>>
>> If ActiveDocument.Variables("Personal").Value = "test" Then
>> CommandButton1.BackColor = &H8000000F
>> End If
>>
>> End Sub
>>
>>
>>
>>
>>
>>
>>
>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>> news:uoWmyp1mHHA.3520@TK2MSFTNGP04.phx.gbl...
>>> You do not have to specifically "Add" a document variable. Assigning a
>>> value to it with
>>>
>>> [document object].Variables("Varname").Value =
>>>
>>> will cause it to be created with the assigned value if it does not
>>> exist, or change the value assigned to it if it already exists.
>>>
>>> --
>>> Hope this helps.
>>>
>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>> services on a paid consulting basis.
>>>
>>> Doug Robbins - Word MVP
>>>
>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>> news:%23qMBtR1mHHA.4628@TK2MSFTNGP06.phx.gbl...
>>>> This did the trick. If anyone has a better way though I am always ready
>>>> to learn.
>>>>
>>>>
>>>> Private Sub CommandButton1_Click()
>>>>
>>>> Unload UserForm1
>>>>
>>>> On Error GoTo Continue
>>>>
>>>> ActiveDocument.Variables.Add Name:="Incomplete"
>>>>
>>>> Continue:
>>>>
>>>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>>>> Me.OptionButton4)
>>>>
>>>> If Title = False Then
>>>>
>>>> ActiveDocument.Variables("Incomplete").Value = True
>>>>
>>>> End If
>>>>
>>>> End Sub
>>>>
>>>>
>>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>>> news:uEF8qlymHHA.1328@TK2MSFTNGP05.phx.gbl...
>>>>> My problem now is that having created the code below, if I access the
>>>>> UserForm again I get an error because the variable all ready exists.
>>>>>
>>>>>
>>>>>
>>>>> Private Sub CommandButton1_Click()
>>>>>
>>>>> Unload UserForm1
>>>>>
>>>>> Title = (Me.OptionButton1 Or Me.OptionButton2 Or Me.OptionButton3 Or
>>>>> Me.OptionButton4)
>>>>>
>>>>> If Title = False Then
>>>>>
>>>>> ActiveDocument.Variables.Add Name:="Incomplete", Value:="True"
>>>>>
>>>>> End If
>>>>>
>>>>> End Sub
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>>>> news:eywUzbymHHA.404@TK2MSFTNGP02.phx.gbl...
>>>>>>I think I may have figured this out. I will be back if things do not
>>>>>>work out. Thanks
>>>>>>
>>>>>> "Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
>>>>>> news:%23LnXvRymHHA.4592@TK2MSFTNGP05.phx.gbl...
>>>>>>> This is what I need to do:
>>>>>>>
>>>>>>> If TextBox1 on UserForm1 is blank when the UserForm is unloaded, I
>>>>>>> want to create a public variable called "incomplete" (would also
>>>>>>> want that variable deleted if it already existed and TextBox1 were
>>>>>>> not blank when the UserForm where unloaded). Then when I open
>>>>>>> UserForm4 if the variable "incomplete" exists, I want the BackColor
>>>>>>> of CommandButton1 to be red.
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>